xref: /linux/drivers/gpu/drm/exynos/exynos_mixer.c (revision 663d8766702c8bb8da31b040b6d6e900b09edbf7)
1d8408326SSeung-Woo Kim /*
2d8408326SSeung-Woo Kim  * Copyright (C) 2011 Samsung Electronics Co.Ltd
3d8408326SSeung-Woo Kim  * Authors:
4d8408326SSeung-Woo Kim  * Seung-Woo Kim <sw0312.kim@samsung.com>
5d8408326SSeung-Woo Kim  *	Inki Dae <inki.dae@samsung.com>
6d8408326SSeung-Woo Kim  *	Joonyoung Shim <jy0922.shim@samsung.com>
7d8408326SSeung-Woo Kim  *
8d8408326SSeung-Woo Kim  * Based on drivers/media/video/s5p-tv/mixer_reg.c
9d8408326SSeung-Woo Kim  *
10d8408326SSeung-Woo Kim  * This program is free software; you can redistribute  it and/or modify it
11d8408326SSeung-Woo Kim  * under  the terms of  the GNU General  Public License as published by the
12d8408326SSeung-Woo Kim  * Free Software Foundation;  either version 2 of the  License, or (at your
13d8408326SSeung-Woo Kim  * option) any later version.
14d8408326SSeung-Woo Kim  *
15d8408326SSeung-Woo Kim  */
16d8408326SSeung-Woo Kim 
17760285e7SDavid Howells #include <drm/drmP.h>
18d8408326SSeung-Woo Kim 
19d8408326SSeung-Woo Kim #include "regs-mixer.h"
20d8408326SSeung-Woo Kim #include "regs-vp.h"
21d8408326SSeung-Woo Kim 
22d8408326SSeung-Woo Kim #include <linux/kernel.h>
23d8408326SSeung-Woo Kim #include <linux/spinlock.h>
24d8408326SSeung-Woo Kim #include <linux/wait.h>
25d8408326SSeung-Woo Kim #include <linux/i2c.h>
26d8408326SSeung-Woo Kim #include <linux/module.h>
27d8408326SSeung-Woo Kim #include <linux/platform_device.h>
28d8408326SSeung-Woo Kim #include <linux/interrupt.h>
29d8408326SSeung-Woo Kim #include <linux/irq.h>
30d8408326SSeung-Woo Kim #include <linux/delay.h>
31d8408326SSeung-Woo Kim #include <linux/pm_runtime.h>
32d8408326SSeung-Woo Kim #include <linux/clk.h>
33d8408326SSeung-Woo Kim #include <linux/regulator/consumer.h>
34d8408326SSeung-Woo Kim 
35d8408326SSeung-Woo Kim #include <drm/exynos_drm.h>
36d8408326SSeung-Woo Kim 
37d8408326SSeung-Woo Kim #include "exynos_drm_drv.h"
38*663d8766SRahul Sharma #include "exynos_drm_crtc.h"
39d8408326SSeung-Woo Kim #include "exynos_drm_hdmi.h"
401055b39fSInki Dae #include "exynos_drm_iommu.h"
4122b21ae6SJoonyoung Shim 
42d8408326SSeung-Woo Kim #define get_mixer_context(dev)	platform_get_drvdata(to_platform_device(dev))
43d8408326SSeung-Woo Kim 
4422b21ae6SJoonyoung Shim struct hdmi_win_data {
4522b21ae6SJoonyoung Shim 	dma_addr_t		dma_addr;
4622b21ae6SJoonyoung Shim 	dma_addr_t		chroma_dma_addr;
4722b21ae6SJoonyoung Shim 	uint32_t		pixel_format;
4822b21ae6SJoonyoung Shim 	unsigned int		bpp;
4922b21ae6SJoonyoung Shim 	unsigned int		crtc_x;
5022b21ae6SJoonyoung Shim 	unsigned int		crtc_y;
5122b21ae6SJoonyoung Shim 	unsigned int		crtc_width;
5222b21ae6SJoonyoung Shim 	unsigned int		crtc_height;
5322b21ae6SJoonyoung Shim 	unsigned int		fb_x;
5422b21ae6SJoonyoung Shim 	unsigned int		fb_y;
5522b21ae6SJoonyoung Shim 	unsigned int		fb_width;
5622b21ae6SJoonyoung Shim 	unsigned int		fb_height;
578dcb96b6SSeung-Woo Kim 	unsigned int		src_width;
588dcb96b6SSeung-Woo Kim 	unsigned int		src_height;
5922b21ae6SJoonyoung Shim 	unsigned int		mode_width;
6022b21ae6SJoonyoung Shim 	unsigned int		mode_height;
6122b21ae6SJoonyoung Shim 	unsigned int		scan_flags;
62db43fd16SPrathyush K 	bool			enabled;
63db43fd16SPrathyush K 	bool			resume;
6422b21ae6SJoonyoung Shim };
6522b21ae6SJoonyoung Shim 
6622b21ae6SJoonyoung Shim struct mixer_resources {
6722b21ae6SJoonyoung Shim 	int			irq;
6822b21ae6SJoonyoung Shim 	void __iomem		*mixer_regs;
6922b21ae6SJoonyoung Shim 	void __iomem		*vp_regs;
7022b21ae6SJoonyoung Shim 	spinlock_t		reg_slock;
7122b21ae6SJoonyoung Shim 	struct clk		*mixer;
7222b21ae6SJoonyoung Shim 	struct clk		*vp;
7322b21ae6SJoonyoung Shim 	struct clk		*sclk_mixer;
7422b21ae6SJoonyoung Shim 	struct clk		*sclk_hdmi;
7522b21ae6SJoonyoung Shim 	struct clk		*sclk_dac;
7622b21ae6SJoonyoung Shim };
7722b21ae6SJoonyoung Shim 
781e123441SRahul Sharma enum mixer_version_id {
791e123441SRahul Sharma 	MXR_VER_0_0_0_16,
801e123441SRahul Sharma 	MXR_VER_16_0_33_0,
811e123441SRahul Sharma };
821e123441SRahul Sharma 
8322b21ae6SJoonyoung Shim struct mixer_context {
84cf8fc4f1SJoonyoung Shim 	struct device		*dev;
851055b39fSInki Dae 	struct drm_device	*drm_dev;
8622b21ae6SJoonyoung Shim 	int			pipe;
8722b21ae6SJoonyoung Shim 	bool			interlace;
88cf8fc4f1SJoonyoung Shim 	bool			powered;
891b8e5747SRahul Sharma 	bool			vp_enabled;
90cf8fc4f1SJoonyoung Shim 	u32			int_en;
9122b21ae6SJoonyoung Shim 
92cf8fc4f1SJoonyoung Shim 	struct mutex		mixer_mutex;
9322b21ae6SJoonyoung Shim 	struct mixer_resources	mixer_res;
94a634dd54SJoonyoung Shim 	struct hdmi_win_data	win_data[MIXER_WIN_NR];
951e123441SRahul Sharma 	enum mixer_version_id	mxr_ver;
961055b39fSInki Dae 	void			*parent_ctx;
976e95d5e6SPrathyush K 	wait_queue_head_t	wait_vsync_queue;
986e95d5e6SPrathyush K 	atomic_t		wait_vsync_event;
991e123441SRahul Sharma };
1001e123441SRahul Sharma 
1011e123441SRahul Sharma struct mixer_drv_data {
1021e123441SRahul Sharma 	enum mixer_version_id	version;
1031b8e5747SRahul Sharma 	bool					is_vp_enabled;
10422b21ae6SJoonyoung Shim };
10522b21ae6SJoonyoung Shim 
106d8408326SSeung-Woo Kim static const u8 filter_y_horiz_tap8[] = {
107d8408326SSeung-Woo Kim 	0,	-1,	-1,	-1,	-1,	-1,	-1,	-1,
108d8408326SSeung-Woo Kim 	-1,	-1,	-1,	-1,	-1,	0,	0,	0,
109d8408326SSeung-Woo Kim 	0,	2,	4,	5,	6,	6,	6,	6,
110d8408326SSeung-Woo Kim 	6,	5,	5,	4,	3,	2,	1,	1,
111d8408326SSeung-Woo Kim 	0,	-6,	-12,	-16,	-18,	-20,	-21,	-20,
112d8408326SSeung-Woo Kim 	-20,	-18,	-16,	-13,	-10,	-8,	-5,	-2,
113d8408326SSeung-Woo Kim 	127,	126,	125,	121,	114,	107,	99,	89,
114d8408326SSeung-Woo Kim 	79,	68,	57,	46,	35,	25,	16,	8,
115d8408326SSeung-Woo Kim };
116d8408326SSeung-Woo Kim 
117d8408326SSeung-Woo Kim static const u8 filter_y_vert_tap4[] = {
118d8408326SSeung-Woo Kim 	0,	-3,	-6,	-8,	-8,	-8,	-8,	-7,
119d8408326SSeung-Woo Kim 	-6,	-5,	-4,	-3,	-2,	-1,	-1,	0,
120d8408326SSeung-Woo Kim 	127,	126,	124,	118,	111,	102,	92,	81,
121d8408326SSeung-Woo Kim 	70,	59,	48,	37,	27,	19,	11,	5,
122d8408326SSeung-Woo Kim 	0,	5,	11,	19,	27,	37,	48,	59,
123d8408326SSeung-Woo Kim 	70,	81,	92,	102,	111,	118,	124,	126,
124d8408326SSeung-Woo Kim 	0,	0,	-1,	-1,	-2,	-3,	-4,	-5,
125d8408326SSeung-Woo Kim 	-6,	-7,	-8,	-8,	-8,	-8,	-6,	-3,
126d8408326SSeung-Woo Kim };
127d8408326SSeung-Woo Kim 
128d8408326SSeung-Woo Kim static const u8 filter_cr_horiz_tap4[] = {
129d8408326SSeung-Woo Kim 	0,	-3,	-6,	-8,	-8,	-8,	-8,	-7,
130d8408326SSeung-Woo Kim 	-6,	-5,	-4,	-3,	-2,	-1,	-1,	0,
131d8408326SSeung-Woo Kim 	127,	126,	124,	118,	111,	102,	92,	81,
132d8408326SSeung-Woo Kim 	70,	59,	48,	37,	27,	19,	11,	5,
133d8408326SSeung-Woo Kim };
134d8408326SSeung-Woo Kim 
135d8408326SSeung-Woo Kim static inline u32 vp_reg_read(struct mixer_resources *res, u32 reg_id)
136d8408326SSeung-Woo Kim {
137d8408326SSeung-Woo Kim 	return readl(res->vp_regs + reg_id);
138d8408326SSeung-Woo Kim }
139d8408326SSeung-Woo Kim 
140d8408326SSeung-Woo Kim static inline void vp_reg_write(struct mixer_resources *res, u32 reg_id,
141d8408326SSeung-Woo Kim 				 u32 val)
142d8408326SSeung-Woo Kim {
143d8408326SSeung-Woo Kim 	writel(val, res->vp_regs + reg_id);
144d8408326SSeung-Woo Kim }
145d8408326SSeung-Woo Kim 
146d8408326SSeung-Woo Kim static inline void vp_reg_writemask(struct mixer_resources *res, u32 reg_id,
147d8408326SSeung-Woo Kim 				 u32 val, u32 mask)
148d8408326SSeung-Woo Kim {
149d8408326SSeung-Woo Kim 	u32 old = vp_reg_read(res, reg_id);
150d8408326SSeung-Woo Kim 
151d8408326SSeung-Woo Kim 	val = (val & mask) | (old & ~mask);
152d8408326SSeung-Woo Kim 	writel(val, res->vp_regs + reg_id);
153d8408326SSeung-Woo Kim }
154d8408326SSeung-Woo Kim 
155d8408326SSeung-Woo Kim static inline u32 mixer_reg_read(struct mixer_resources *res, u32 reg_id)
156d8408326SSeung-Woo Kim {
157d8408326SSeung-Woo Kim 	return readl(res->mixer_regs + reg_id);
158d8408326SSeung-Woo Kim }
159d8408326SSeung-Woo Kim 
160d8408326SSeung-Woo Kim static inline void mixer_reg_write(struct mixer_resources *res, u32 reg_id,
161d8408326SSeung-Woo Kim 				 u32 val)
162d8408326SSeung-Woo Kim {
163d8408326SSeung-Woo Kim 	writel(val, res->mixer_regs + reg_id);
164d8408326SSeung-Woo Kim }
165d8408326SSeung-Woo Kim 
166d8408326SSeung-Woo Kim static inline void mixer_reg_writemask(struct mixer_resources *res,
167d8408326SSeung-Woo Kim 				 u32 reg_id, u32 val, u32 mask)
168d8408326SSeung-Woo Kim {
169d8408326SSeung-Woo Kim 	u32 old = mixer_reg_read(res, reg_id);
170d8408326SSeung-Woo Kim 
171d8408326SSeung-Woo Kim 	val = (val & mask) | (old & ~mask);
172d8408326SSeung-Woo Kim 	writel(val, res->mixer_regs + reg_id);
173d8408326SSeung-Woo Kim }
174d8408326SSeung-Woo Kim 
175d8408326SSeung-Woo Kim static void mixer_regs_dump(struct mixer_context *ctx)
176d8408326SSeung-Woo Kim {
177d8408326SSeung-Woo Kim #define DUMPREG(reg_id) \
178d8408326SSeung-Woo Kim do { \
179d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS(#reg_id " = %08x\n", \
180d8408326SSeung-Woo Kim 		(u32)readl(ctx->mixer_res.mixer_regs + reg_id)); \
181d8408326SSeung-Woo Kim } while (0)
182d8408326SSeung-Woo Kim 
183d8408326SSeung-Woo Kim 	DUMPREG(MXR_STATUS);
184d8408326SSeung-Woo Kim 	DUMPREG(MXR_CFG);
185d8408326SSeung-Woo Kim 	DUMPREG(MXR_INT_EN);
186d8408326SSeung-Woo Kim 	DUMPREG(MXR_INT_STATUS);
187d8408326SSeung-Woo Kim 
188d8408326SSeung-Woo Kim 	DUMPREG(MXR_LAYER_CFG);
189d8408326SSeung-Woo Kim 	DUMPREG(MXR_VIDEO_CFG);
190d8408326SSeung-Woo Kim 
191d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_CFG);
192d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_BASE);
193d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_SPAN);
194d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_WH);
195d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_SXY);
196d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC0_DXY);
197d8408326SSeung-Woo Kim 
198d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_CFG);
199d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_BASE);
200d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_SPAN);
201d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_WH);
202d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_SXY);
203d8408326SSeung-Woo Kim 	DUMPREG(MXR_GRAPHIC1_DXY);
204d8408326SSeung-Woo Kim #undef DUMPREG
205d8408326SSeung-Woo Kim }
206d8408326SSeung-Woo Kim 
207d8408326SSeung-Woo Kim static void vp_regs_dump(struct mixer_context *ctx)
208d8408326SSeung-Woo Kim {
209d8408326SSeung-Woo Kim #define DUMPREG(reg_id) \
210d8408326SSeung-Woo Kim do { \
211d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS(#reg_id " = %08x\n", \
212d8408326SSeung-Woo Kim 		(u32) readl(ctx->mixer_res.vp_regs + reg_id)); \
213d8408326SSeung-Woo Kim } while (0)
214d8408326SSeung-Woo Kim 
215d8408326SSeung-Woo Kim 	DUMPREG(VP_ENABLE);
216d8408326SSeung-Woo Kim 	DUMPREG(VP_SRESET);
217d8408326SSeung-Woo Kim 	DUMPREG(VP_SHADOW_UPDATE);
218d8408326SSeung-Woo Kim 	DUMPREG(VP_FIELD_ID);
219d8408326SSeung-Woo Kim 	DUMPREG(VP_MODE);
220d8408326SSeung-Woo Kim 	DUMPREG(VP_IMG_SIZE_Y);
221d8408326SSeung-Woo Kim 	DUMPREG(VP_IMG_SIZE_C);
222d8408326SSeung-Woo Kim 	DUMPREG(VP_PER_RATE_CTRL);
223d8408326SSeung-Woo Kim 	DUMPREG(VP_TOP_Y_PTR);
224d8408326SSeung-Woo Kim 	DUMPREG(VP_BOT_Y_PTR);
225d8408326SSeung-Woo Kim 	DUMPREG(VP_TOP_C_PTR);
226d8408326SSeung-Woo Kim 	DUMPREG(VP_BOT_C_PTR);
227d8408326SSeung-Woo Kim 	DUMPREG(VP_ENDIAN_MODE);
228d8408326SSeung-Woo Kim 	DUMPREG(VP_SRC_H_POSITION);
229d8408326SSeung-Woo Kim 	DUMPREG(VP_SRC_V_POSITION);
230d8408326SSeung-Woo Kim 	DUMPREG(VP_SRC_WIDTH);
231d8408326SSeung-Woo Kim 	DUMPREG(VP_SRC_HEIGHT);
232d8408326SSeung-Woo Kim 	DUMPREG(VP_DST_H_POSITION);
233d8408326SSeung-Woo Kim 	DUMPREG(VP_DST_V_POSITION);
234d8408326SSeung-Woo Kim 	DUMPREG(VP_DST_WIDTH);
235d8408326SSeung-Woo Kim 	DUMPREG(VP_DST_HEIGHT);
236d8408326SSeung-Woo Kim 	DUMPREG(VP_H_RATIO);
237d8408326SSeung-Woo Kim 	DUMPREG(VP_V_RATIO);
238d8408326SSeung-Woo Kim 
239d8408326SSeung-Woo Kim #undef DUMPREG
240d8408326SSeung-Woo Kim }
241d8408326SSeung-Woo Kim 
242d8408326SSeung-Woo Kim static inline void vp_filter_set(struct mixer_resources *res,
243d8408326SSeung-Woo Kim 		int reg_id, const u8 *data, unsigned int size)
244d8408326SSeung-Woo Kim {
245d8408326SSeung-Woo Kim 	/* assure 4-byte align */
246d8408326SSeung-Woo Kim 	BUG_ON(size & 3);
247d8408326SSeung-Woo Kim 	for (; size; size -= 4, reg_id += 4, data += 4) {
248d8408326SSeung-Woo Kim 		u32 val = (data[0] << 24) |  (data[1] << 16) |
249d8408326SSeung-Woo Kim 			(data[2] << 8) | data[3];
250d8408326SSeung-Woo Kim 		vp_reg_write(res, reg_id, val);
251d8408326SSeung-Woo Kim 	}
252d8408326SSeung-Woo Kim }
253d8408326SSeung-Woo Kim 
254d8408326SSeung-Woo Kim static void vp_default_filter(struct mixer_resources *res)
255d8408326SSeung-Woo Kim {
256d8408326SSeung-Woo Kim 	vp_filter_set(res, VP_POLY8_Y0_LL,
257e25e1b66SSachin Kamat 		filter_y_horiz_tap8, sizeof(filter_y_horiz_tap8));
258d8408326SSeung-Woo Kim 	vp_filter_set(res, VP_POLY4_Y0_LL,
259e25e1b66SSachin Kamat 		filter_y_vert_tap4, sizeof(filter_y_vert_tap4));
260d8408326SSeung-Woo Kim 	vp_filter_set(res, VP_POLY4_C0_LL,
261e25e1b66SSachin Kamat 		filter_cr_horiz_tap4, sizeof(filter_cr_horiz_tap4));
262d8408326SSeung-Woo Kim }
263d8408326SSeung-Woo Kim 
264d8408326SSeung-Woo Kim static void mixer_vsync_set_update(struct mixer_context *ctx, bool enable)
265d8408326SSeung-Woo Kim {
266d8408326SSeung-Woo Kim 	struct mixer_resources *res = &ctx->mixer_res;
267d8408326SSeung-Woo Kim 
268d8408326SSeung-Woo Kim 	/* block update on vsync */
269d8408326SSeung-Woo Kim 	mixer_reg_writemask(res, MXR_STATUS, enable ?
270d8408326SSeung-Woo Kim 			MXR_STATUS_SYNC_ENABLE : 0, MXR_STATUS_SYNC_ENABLE);
271d8408326SSeung-Woo Kim 
2721b8e5747SRahul Sharma 	if (ctx->vp_enabled)
273d8408326SSeung-Woo Kim 		vp_reg_write(res, VP_SHADOW_UPDATE, enable ?
274d8408326SSeung-Woo Kim 			VP_SHADOW_UPDATE_ENABLE : 0);
275d8408326SSeung-Woo Kim }
276d8408326SSeung-Woo Kim 
277d8408326SSeung-Woo Kim static void mixer_cfg_scan(struct mixer_context *ctx, unsigned int height)
278d8408326SSeung-Woo Kim {
279d8408326SSeung-Woo Kim 	struct mixer_resources *res = &ctx->mixer_res;
280d8408326SSeung-Woo Kim 	u32 val;
281d8408326SSeung-Woo Kim 
282d8408326SSeung-Woo Kim 	/* choosing between interlace and progressive mode */
283d8408326SSeung-Woo Kim 	val = (ctx->interlace ? MXR_CFG_SCAN_INTERLACE :
284d8408326SSeung-Woo Kim 				MXR_CFG_SCAN_PROGRASSIVE);
285d8408326SSeung-Woo Kim 
286d8408326SSeung-Woo Kim 	/* choosing between porper HD and SD mode */
287d8408326SSeung-Woo Kim 	if (height == 480)
288d8408326SSeung-Woo Kim 		val |= MXR_CFG_SCAN_NTSC | MXR_CFG_SCAN_SD;
289d8408326SSeung-Woo Kim 	else if (height == 576)
290d8408326SSeung-Woo Kim 		val |= MXR_CFG_SCAN_PAL | MXR_CFG_SCAN_SD;
291d8408326SSeung-Woo Kim 	else if (height == 720)
292d8408326SSeung-Woo Kim 		val |= MXR_CFG_SCAN_HD_720 | MXR_CFG_SCAN_HD;
293d8408326SSeung-Woo Kim 	else if (height == 1080)
294d8408326SSeung-Woo Kim 		val |= MXR_CFG_SCAN_HD_1080 | MXR_CFG_SCAN_HD;
295d8408326SSeung-Woo Kim 	else
296d8408326SSeung-Woo Kim 		val |= MXR_CFG_SCAN_HD_720 | MXR_CFG_SCAN_HD;
297d8408326SSeung-Woo Kim 
298d8408326SSeung-Woo Kim 	mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_SCAN_MASK);
299d8408326SSeung-Woo Kim }
300d8408326SSeung-Woo Kim 
301d8408326SSeung-Woo Kim static void mixer_cfg_rgb_fmt(struct mixer_context *ctx, unsigned int height)
302d8408326SSeung-Woo Kim {
303d8408326SSeung-Woo Kim 	struct mixer_resources *res = &ctx->mixer_res;
304d8408326SSeung-Woo Kim 	u32 val;
305d8408326SSeung-Woo Kim 
306d8408326SSeung-Woo Kim 	if (height == 480) {
307d8408326SSeung-Woo Kim 		val = MXR_CFG_RGB601_0_255;
308d8408326SSeung-Woo Kim 	} else if (height == 576) {
309d8408326SSeung-Woo Kim 		val = MXR_CFG_RGB601_0_255;
310d8408326SSeung-Woo Kim 	} else if (height == 720) {
311d8408326SSeung-Woo Kim 		val = MXR_CFG_RGB709_16_235;
312d8408326SSeung-Woo Kim 		mixer_reg_write(res, MXR_CM_COEFF_Y,
313d8408326SSeung-Woo Kim 				(1 << 30) | (94 << 20) | (314 << 10) |
314d8408326SSeung-Woo Kim 				(32 << 0));
315d8408326SSeung-Woo Kim 		mixer_reg_write(res, MXR_CM_COEFF_CB,
316d8408326SSeung-Woo Kim 				(972 << 20) | (851 << 10) | (225 << 0));
317d8408326SSeung-Woo Kim 		mixer_reg_write(res, MXR_CM_COEFF_CR,
318d8408326SSeung-Woo Kim 				(225 << 20) | (820 << 10) | (1004 << 0));
319d8408326SSeung-Woo Kim 	} else if (height == 1080) {
320d8408326SSeung-Woo Kim 		val = MXR_CFG_RGB709_16_235;
321d8408326SSeung-Woo Kim 		mixer_reg_write(res, MXR_CM_COEFF_Y,
322d8408326SSeung-Woo Kim 				(1 << 30) | (94 << 20) | (314 << 10) |
323d8408326SSeung-Woo Kim 				(32 << 0));
324d8408326SSeung-Woo Kim 		mixer_reg_write(res, MXR_CM_COEFF_CB,
325d8408326SSeung-Woo Kim 				(972 << 20) | (851 << 10) | (225 << 0));
326d8408326SSeung-Woo Kim 		mixer_reg_write(res, MXR_CM_COEFF_CR,
327d8408326SSeung-Woo Kim 				(225 << 20) | (820 << 10) | (1004 << 0));
328d8408326SSeung-Woo Kim 	} else {
329d8408326SSeung-Woo Kim 		val = MXR_CFG_RGB709_16_235;
330d8408326SSeung-Woo Kim 		mixer_reg_write(res, MXR_CM_COEFF_Y,
331d8408326SSeung-Woo Kim 				(1 << 30) | (94 << 20) | (314 << 10) |
332d8408326SSeung-Woo Kim 				(32 << 0));
333d8408326SSeung-Woo Kim 		mixer_reg_write(res, MXR_CM_COEFF_CB,
334d8408326SSeung-Woo Kim 				(972 << 20) | (851 << 10) | (225 << 0));
335d8408326SSeung-Woo Kim 		mixer_reg_write(res, MXR_CM_COEFF_CR,
336d8408326SSeung-Woo Kim 				(225 << 20) | (820 << 10) | (1004 << 0));
337d8408326SSeung-Woo Kim 	}
338d8408326SSeung-Woo Kim 
339d8408326SSeung-Woo Kim 	mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_RGB_FMT_MASK);
340d8408326SSeung-Woo Kim }
341d8408326SSeung-Woo Kim 
342d8408326SSeung-Woo Kim static void mixer_cfg_layer(struct mixer_context *ctx, int win, bool enable)
343d8408326SSeung-Woo Kim {
344d8408326SSeung-Woo Kim 	struct mixer_resources *res = &ctx->mixer_res;
345d8408326SSeung-Woo Kim 	u32 val = enable ? ~0 : 0;
346d8408326SSeung-Woo Kim 
347d8408326SSeung-Woo Kim 	switch (win) {
348d8408326SSeung-Woo Kim 	case 0:
349d8408326SSeung-Woo Kim 		mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_GRP0_ENABLE);
350d8408326SSeung-Woo Kim 		break;
351d8408326SSeung-Woo Kim 	case 1:
352d8408326SSeung-Woo Kim 		mixer_reg_writemask(res, MXR_CFG, val, MXR_CFG_GRP1_ENABLE);
353d8408326SSeung-Woo Kim 		break;
354d8408326SSeung-Woo Kim 	case 2:
3551b8e5747SRahul Sharma 		if (ctx->vp_enabled) {
356d8408326SSeung-Woo Kim 			vp_reg_writemask(res, VP_ENABLE, val, VP_ENABLE_ON);
3571b8e5747SRahul Sharma 			mixer_reg_writemask(res, MXR_CFG, val,
3581b8e5747SRahul Sharma 				MXR_CFG_VP_ENABLE);
3591b8e5747SRahul Sharma 		}
360d8408326SSeung-Woo Kim 		break;
361d8408326SSeung-Woo Kim 	}
362d8408326SSeung-Woo Kim }
363d8408326SSeung-Woo Kim 
364d8408326SSeung-Woo Kim static void mixer_run(struct mixer_context *ctx)
365d8408326SSeung-Woo Kim {
366d8408326SSeung-Woo Kim 	struct mixer_resources *res = &ctx->mixer_res;
367d8408326SSeung-Woo Kim 
368d8408326SSeung-Woo Kim 	mixer_reg_writemask(res, MXR_STATUS, ~0, MXR_STATUS_REG_RUN);
369d8408326SSeung-Woo Kim 
370d8408326SSeung-Woo Kim 	mixer_regs_dump(ctx);
371d8408326SSeung-Woo Kim }
372d8408326SSeung-Woo Kim 
373d8408326SSeung-Woo Kim static void vp_video_buffer(struct mixer_context *ctx, int win)
374d8408326SSeung-Woo Kim {
375d8408326SSeung-Woo Kim 	struct mixer_resources *res = &ctx->mixer_res;
376d8408326SSeung-Woo Kim 	unsigned long flags;
377d8408326SSeung-Woo Kim 	struct hdmi_win_data *win_data;
378d8408326SSeung-Woo Kim 	unsigned int x_ratio, y_ratio;
379d8408326SSeung-Woo Kim 	unsigned int buf_num;
380d8408326SSeung-Woo Kim 	dma_addr_t luma_addr[2], chroma_addr[2];
381d8408326SSeung-Woo Kim 	bool tiled_mode = false;
382d8408326SSeung-Woo Kim 	bool crcb_mode = false;
383d8408326SSeung-Woo Kim 	u32 val;
384d8408326SSeung-Woo Kim 
385d8408326SSeung-Woo Kim 	win_data = &ctx->win_data[win];
386d8408326SSeung-Woo Kim 
387d8408326SSeung-Woo Kim 	switch (win_data->pixel_format) {
388d8408326SSeung-Woo Kim 	case DRM_FORMAT_NV12MT:
389d8408326SSeung-Woo Kim 		tiled_mode = true;
390363b06aaSVille Syrjälä 	case DRM_FORMAT_NV12:
391d8408326SSeung-Woo Kim 		crcb_mode = false;
392d8408326SSeung-Woo Kim 		buf_num = 2;
393d8408326SSeung-Woo Kim 		break;
394d8408326SSeung-Woo Kim 	/* TODO: single buffer format NV12, NV21 */
395d8408326SSeung-Woo Kim 	default:
396d8408326SSeung-Woo Kim 		/* ignore pixel format at disable time */
397d8408326SSeung-Woo Kim 		if (!win_data->dma_addr)
398d8408326SSeung-Woo Kim 			break;
399d8408326SSeung-Woo Kim 
400d8408326SSeung-Woo Kim 		DRM_ERROR("pixel format for vp is wrong [%d].\n",
401d8408326SSeung-Woo Kim 				win_data->pixel_format);
402d8408326SSeung-Woo Kim 		return;
403d8408326SSeung-Woo Kim 	}
404d8408326SSeung-Woo Kim 
405d8408326SSeung-Woo Kim 	/* scaling feature: (src << 16) / dst */
4068dcb96b6SSeung-Woo Kim 	x_ratio = (win_data->src_width << 16) / win_data->crtc_width;
4078dcb96b6SSeung-Woo Kim 	y_ratio = (win_data->src_height << 16) / win_data->crtc_height;
408d8408326SSeung-Woo Kim 
409d8408326SSeung-Woo Kim 	if (buf_num == 2) {
410d8408326SSeung-Woo Kim 		luma_addr[0] = win_data->dma_addr;
411d8408326SSeung-Woo Kim 		chroma_addr[0] = win_data->chroma_dma_addr;
412d8408326SSeung-Woo Kim 	} else {
413d8408326SSeung-Woo Kim 		luma_addr[0] = win_data->dma_addr;
414d8408326SSeung-Woo Kim 		chroma_addr[0] = win_data->dma_addr
4158dcb96b6SSeung-Woo Kim 			+ (win_data->fb_width * win_data->fb_height);
416d8408326SSeung-Woo Kim 	}
417d8408326SSeung-Woo Kim 
418d8408326SSeung-Woo Kim 	if (win_data->scan_flags & DRM_MODE_FLAG_INTERLACE) {
419d8408326SSeung-Woo Kim 		ctx->interlace = true;
420d8408326SSeung-Woo Kim 		if (tiled_mode) {
421d8408326SSeung-Woo Kim 			luma_addr[1] = luma_addr[0] + 0x40;
422d8408326SSeung-Woo Kim 			chroma_addr[1] = chroma_addr[0] + 0x40;
423d8408326SSeung-Woo Kim 		} else {
4248dcb96b6SSeung-Woo Kim 			luma_addr[1] = luma_addr[0] + win_data->fb_width;
4258dcb96b6SSeung-Woo Kim 			chroma_addr[1] = chroma_addr[0] + win_data->fb_width;
426d8408326SSeung-Woo Kim 		}
427d8408326SSeung-Woo Kim 	} else {
428d8408326SSeung-Woo Kim 		ctx->interlace = false;
429d8408326SSeung-Woo Kim 		luma_addr[1] = 0;
430d8408326SSeung-Woo Kim 		chroma_addr[1] = 0;
431d8408326SSeung-Woo Kim 	}
432d8408326SSeung-Woo Kim 
433d8408326SSeung-Woo Kim 	spin_lock_irqsave(&res->reg_slock, flags);
434d8408326SSeung-Woo Kim 	mixer_vsync_set_update(ctx, false);
435d8408326SSeung-Woo Kim 
436d8408326SSeung-Woo Kim 	/* interlace or progressive scan mode */
437d8408326SSeung-Woo Kim 	val = (ctx->interlace ? ~0 : 0);
438d8408326SSeung-Woo Kim 	vp_reg_writemask(res, VP_MODE, val, VP_MODE_LINE_SKIP);
439d8408326SSeung-Woo Kim 
440d8408326SSeung-Woo Kim 	/* setup format */
441d8408326SSeung-Woo Kim 	val = (crcb_mode ? VP_MODE_NV21 : VP_MODE_NV12);
442d8408326SSeung-Woo Kim 	val |= (tiled_mode ? VP_MODE_MEM_TILED : VP_MODE_MEM_LINEAR);
443d8408326SSeung-Woo Kim 	vp_reg_writemask(res, VP_MODE, val, VP_MODE_FMT_MASK);
444d8408326SSeung-Woo Kim 
445d8408326SSeung-Woo Kim 	/* setting size of input image */
4468dcb96b6SSeung-Woo Kim 	vp_reg_write(res, VP_IMG_SIZE_Y, VP_IMG_HSIZE(win_data->fb_width) |
4478dcb96b6SSeung-Woo Kim 		VP_IMG_VSIZE(win_data->fb_height));
448d8408326SSeung-Woo Kim 	/* chroma height has to reduced by 2 to avoid chroma distorions */
4498dcb96b6SSeung-Woo Kim 	vp_reg_write(res, VP_IMG_SIZE_C, VP_IMG_HSIZE(win_data->fb_width) |
4508dcb96b6SSeung-Woo Kim 		VP_IMG_VSIZE(win_data->fb_height / 2));
451d8408326SSeung-Woo Kim 
4528dcb96b6SSeung-Woo Kim 	vp_reg_write(res, VP_SRC_WIDTH, win_data->src_width);
4538dcb96b6SSeung-Woo Kim 	vp_reg_write(res, VP_SRC_HEIGHT, win_data->src_height);
454d8408326SSeung-Woo Kim 	vp_reg_write(res, VP_SRC_H_POSITION,
4558dcb96b6SSeung-Woo Kim 			VP_SRC_H_POSITION_VAL(win_data->fb_x));
4568dcb96b6SSeung-Woo Kim 	vp_reg_write(res, VP_SRC_V_POSITION, win_data->fb_y);
457d8408326SSeung-Woo Kim 
4588dcb96b6SSeung-Woo Kim 	vp_reg_write(res, VP_DST_WIDTH, win_data->crtc_width);
4598dcb96b6SSeung-Woo Kim 	vp_reg_write(res, VP_DST_H_POSITION, win_data->crtc_x);
460d8408326SSeung-Woo Kim 	if (ctx->interlace) {
4618dcb96b6SSeung-Woo Kim 		vp_reg_write(res, VP_DST_HEIGHT, win_data->crtc_height / 2);
4628dcb96b6SSeung-Woo Kim 		vp_reg_write(res, VP_DST_V_POSITION, win_data->crtc_y / 2);
463d8408326SSeung-Woo Kim 	} else {
4648dcb96b6SSeung-Woo Kim 		vp_reg_write(res, VP_DST_HEIGHT, win_data->crtc_height);
4658dcb96b6SSeung-Woo Kim 		vp_reg_write(res, VP_DST_V_POSITION, win_data->crtc_y);
466d8408326SSeung-Woo Kim 	}
467d8408326SSeung-Woo Kim 
468d8408326SSeung-Woo Kim 	vp_reg_write(res, VP_H_RATIO, x_ratio);
469d8408326SSeung-Woo Kim 	vp_reg_write(res, VP_V_RATIO, y_ratio);
470d8408326SSeung-Woo Kim 
471d8408326SSeung-Woo Kim 	vp_reg_write(res, VP_ENDIAN_MODE, VP_ENDIAN_MODE_LITTLE);
472d8408326SSeung-Woo Kim 
473d8408326SSeung-Woo Kim 	/* set buffer address to vp */
474d8408326SSeung-Woo Kim 	vp_reg_write(res, VP_TOP_Y_PTR, luma_addr[0]);
475d8408326SSeung-Woo Kim 	vp_reg_write(res, VP_BOT_Y_PTR, luma_addr[1]);
476d8408326SSeung-Woo Kim 	vp_reg_write(res, VP_TOP_C_PTR, chroma_addr[0]);
477d8408326SSeung-Woo Kim 	vp_reg_write(res, VP_BOT_C_PTR, chroma_addr[1]);
478d8408326SSeung-Woo Kim 
4798dcb96b6SSeung-Woo Kim 	mixer_cfg_scan(ctx, win_data->mode_height);
4808dcb96b6SSeung-Woo Kim 	mixer_cfg_rgb_fmt(ctx, win_data->mode_height);
481d8408326SSeung-Woo Kim 	mixer_cfg_layer(ctx, win, true);
482d8408326SSeung-Woo Kim 	mixer_run(ctx);
483d8408326SSeung-Woo Kim 
484d8408326SSeung-Woo Kim 	mixer_vsync_set_update(ctx, true);
485d8408326SSeung-Woo Kim 	spin_unlock_irqrestore(&res->reg_slock, flags);
486d8408326SSeung-Woo Kim 
487d8408326SSeung-Woo Kim 	vp_regs_dump(ctx);
488d8408326SSeung-Woo Kim }
489d8408326SSeung-Woo Kim 
490aaf8b49eSRahul Sharma static void mixer_layer_update(struct mixer_context *ctx)
491aaf8b49eSRahul Sharma {
492aaf8b49eSRahul Sharma 	struct mixer_resources *res = &ctx->mixer_res;
493aaf8b49eSRahul Sharma 	u32 val;
494aaf8b49eSRahul Sharma 
495aaf8b49eSRahul Sharma 	val = mixer_reg_read(res, MXR_CFG);
496aaf8b49eSRahul Sharma 
497aaf8b49eSRahul Sharma 	/* allow one update per vsync only */
498aaf8b49eSRahul Sharma 	if (!(val & MXR_CFG_LAYER_UPDATE_COUNT_MASK))
499aaf8b49eSRahul Sharma 		mixer_reg_writemask(res, MXR_CFG, ~0, MXR_CFG_LAYER_UPDATE);
500aaf8b49eSRahul Sharma }
501aaf8b49eSRahul Sharma 
502d8408326SSeung-Woo Kim static void mixer_graph_buffer(struct mixer_context *ctx, int win)
503d8408326SSeung-Woo Kim {
504d8408326SSeung-Woo Kim 	struct mixer_resources *res = &ctx->mixer_res;
505d8408326SSeung-Woo Kim 	unsigned long flags;
506d8408326SSeung-Woo Kim 	struct hdmi_win_data *win_data;
507d8408326SSeung-Woo Kim 	unsigned int x_ratio, y_ratio;
508d8408326SSeung-Woo Kim 	unsigned int src_x_offset, src_y_offset, dst_x_offset, dst_y_offset;
509d8408326SSeung-Woo Kim 	dma_addr_t dma_addr;
510d8408326SSeung-Woo Kim 	unsigned int fmt;
511d8408326SSeung-Woo Kim 	u32 val;
512d8408326SSeung-Woo Kim 
513d8408326SSeung-Woo Kim 	win_data = &ctx->win_data[win];
514d8408326SSeung-Woo Kim 
515d8408326SSeung-Woo Kim 	#define RGB565 4
516d8408326SSeung-Woo Kim 	#define ARGB1555 5
517d8408326SSeung-Woo Kim 	#define ARGB4444 6
518d8408326SSeung-Woo Kim 	#define ARGB8888 7
519d8408326SSeung-Woo Kim 
520d8408326SSeung-Woo Kim 	switch (win_data->bpp) {
521d8408326SSeung-Woo Kim 	case 16:
522d8408326SSeung-Woo Kim 		fmt = ARGB4444;
523d8408326SSeung-Woo Kim 		break;
524d8408326SSeung-Woo Kim 	case 32:
525d8408326SSeung-Woo Kim 		fmt = ARGB8888;
526d8408326SSeung-Woo Kim 		break;
527d8408326SSeung-Woo Kim 	default:
528d8408326SSeung-Woo Kim 		fmt = ARGB8888;
529d8408326SSeung-Woo Kim 	}
530d8408326SSeung-Woo Kim 
531d8408326SSeung-Woo Kim 	/* 2x scaling feature */
532d8408326SSeung-Woo Kim 	x_ratio = 0;
533d8408326SSeung-Woo Kim 	y_ratio = 0;
534d8408326SSeung-Woo Kim 
535d8408326SSeung-Woo Kim 	dst_x_offset = win_data->crtc_x;
536d8408326SSeung-Woo Kim 	dst_y_offset = win_data->crtc_y;
537d8408326SSeung-Woo Kim 
538d8408326SSeung-Woo Kim 	/* converting dma address base and source offset */
5398dcb96b6SSeung-Woo Kim 	dma_addr = win_data->dma_addr
5408dcb96b6SSeung-Woo Kim 		+ (win_data->fb_x * win_data->bpp >> 3)
5418dcb96b6SSeung-Woo Kim 		+ (win_data->fb_y * win_data->fb_width * win_data->bpp >> 3);
542d8408326SSeung-Woo Kim 	src_x_offset = 0;
543d8408326SSeung-Woo Kim 	src_y_offset = 0;
544d8408326SSeung-Woo Kim 
545d8408326SSeung-Woo Kim 	if (win_data->scan_flags & DRM_MODE_FLAG_INTERLACE)
546d8408326SSeung-Woo Kim 		ctx->interlace = true;
547d8408326SSeung-Woo Kim 	else
548d8408326SSeung-Woo Kim 		ctx->interlace = false;
549d8408326SSeung-Woo Kim 
550d8408326SSeung-Woo Kim 	spin_lock_irqsave(&res->reg_slock, flags);
551d8408326SSeung-Woo Kim 	mixer_vsync_set_update(ctx, false);
552d8408326SSeung-Woo Kim 
553d8408326SSeung-Woo Kim 	/* setup format */
554d8408326SSeung-Woo Kim 	mixer_reg_writemask(res, MXR_GRAPHIC_CFG(win),
555d8408326SSeung-Woo Kim 		MXR_GRP_CFG_FORMAT_VAL(fmt), MXR_GRP_CFG_FORMAT_MASK);
556d8408326SSeung-Woo Kim 
557d8408326SSeung-Woo Kim 	/* setup geometry */
5588dcb96b6SSeung-Woo Kim 	mixer_reg_write(res, MXR_GRAPHIC_SPAN(win), win_data->fb_width);
559d8408326SSeung-Woo Kim 
5608dcb96b6SSeung-Woo Kim 	val  = MXR_GRP_WH_WIDTH(win_data->crtc_width);
5618dcb96b6SSeung-Woo Kim 	val |= MXR_GRP_WH_HEIGHT(win_data->crtc_height);
562d8408326SSeung-Woo Kim 	val |= MXR_GRP_WH_H_SCALE(x_ratio);
563d8408326SSeung-Woo Kim 	val |= MXR_GRP_WH_V_SCALE(y_ratio);
564d8408326SSeung-Woo Kim 	mixer_reg_write(res, MXR_GRAPHIC_WH(win), val);
565d8408326SSeung-Woo Kim 
566d8408326SSeung-Woo Kim 	/* setup offsets in source image */
567d8408326SSeung-Woo Kim 	val  = MXR_GRP_SXY_SX(src_x_offset);
568d8408326SSeung-Woo Kim 	val |= MXR_GRP_SXY_SY(src_y_offset);
569d8408326SSeung-Woo Kim 	mixer_reg_write(res, MXR_GRAPHIC_SXY(win), val);
570d8408326SSeung-Woo Kim 
571d8408326SSeung-Woo Kim 	/* setup offsets in display image */
572d8408326SSeung-Woo Kim 	val  = MXR_GRP_DXY_DX(dst_x_offset);
573d8408326SSeung-Woo Kim 	val |= MXR_GRP_DXY_DY(dst_y_offset);
574d8408326SSeung-Woo Kim 	mixer_reg_write(res, MXR_GRAPHIC_DXY(win), val);
575d8408326SSeung-Woo Kim 
576d8408326SSeung-Woo Kim 	/* set buffer address to mixer */
577d8408326SSeung-Woo Kim 	mixer_reg_write(res, MXR_GRAPHIC_BASE(win), dma_addr);
578d8408326SSeung-Woo Kim 
5798dcb96b6SSeung-Woo Kim 	mixer_cfg_scan(ctx, win_data->mode_height);
5808dcb96b6SSeung-Woo Kim 	mixer_cfg_rgb_fmt(ctx, win_data->mode_height);
581d8408326SSeung-Woo Kim 	mixer_cfg_layer(ctx, win, true);
582aaf8b49eSRahul Sharma 
583aaf8b49eSRahul Sharma 	/* layer update mandatory for mixer 16.0.33.0 */
584aaf8b49eSRahul Sharma 	if (ctx->mxr_ver == MXR_VER_16_0_33_0)
585aaf8b49eSRahul Sharma 		mixer_layer_update(ctx);
586aaf8b49eSRahul Sharma 
587d8408326SSeung-Woo Kim 	mixer_run(ctx);
588d8408326SSeung-Woo Kim 
589d8408326SSeung-Woo Kim 	mixer_vsync_set_update(ctx, true);
590d8408326SSeung-Woo Kim 	spin_unlock_irqrestore(&res->reg_slock, flags);
591d8408326SSeung-Woo Kim }
592d8408326SSeung-Woo Kim 
593d8408326SSeung-Woo Kim static void vp_win_reset(struct mixer_context *ctx)
594d8408326SSeung-Woo Kim {
595d8408326SSeung-Woo Kim 	struct mixer_resources *res = &ctx->mixer_res;
596d8408326SSeung-Woo Kim 	int tries = 100;
597d8408326SSeung-Woo Kim 
598d8408326SSeung-Woo Kim 	vp_reg_write(res, VP_SRESET, VP_SRESET_PROCESSING);
599d8408326SSeung-Woo Kim 	for (tries = 100; tries; --tries) {
600d8408326SSeung-Woo Kim 		/* waiting until VP_SRESET_PROCESSING is 0 */
601d8408326SSeung-Woo Kim 		if (~vp_reg_read(res, VP_SRESET) & VP_SRESET_PROCESSING)
602d8408326SSeung-Woo Kim 			break;
603d8408326SSeung-Woo Kim 		mdelay(10);
604d8408326SSeung-Woo Kim 	}
605d8408326SSeung-Woo Kim 	WARN(tries == 0, "failed to reset Video Processor\n");
606d8408326SSeung-Woo Kim }
607d8408326SSeung-Woo Kim 
608cf8fc4f1SJoonyoung Shim static void mixer_win_reset(struct mixer_context *ctx)
609cf8fc4f1SJoonyoung Shim {
610cf8fc4f1SJoonyoung Shim 	struct mixer_resources *res = &ctx->mixer_res;
611cf8fc4f1SJoonyoung Shim 	unsigned long flags;
612cf8fc4f1SJoonyoung Shim 	u32 val; /* value stored to register */
613cf8fc4f1SJoonyoung Shim 
614cf8fc4f1SJoonyoung Shim 	spin_lock_irqsave(&res->reg_slock, flags);
615cf8fc4f1SJoonyoung Shim 	mixer_vsync_set_update(ctx, false);
616cf8fc4f1SJoonyoung Shim 
617cf8fc4f1SJoonyoung Shim 	mixer_reg_writemask(res, MXR_CFG, MXR_CFG_DST_HDMI, MXR_CFG_DST_MASK);
618cf8fc4f1SJoonyoung Shim 
619cf8fc4f1SJoonyoung Shim 	/* set output in RGB888 mode */
620cf8fc4f1SJoonyoung Shim 	mixer_reg_writemask(res, MXR_CFG, MXR_CFG_OUT_RGB888, MXR_CFG_OUT_MASK);
621cf8fc4f1SJoonyoung Shim 
622cf8fc4f1SJoonyoung Shim 	/* 16 beat burst in DMA */
623cf8fc4f1SJoonyoung Shim 	mixer_reg_writemask(res, MXR_STATUS, MXR_STATUS_16_BURST,
624cf8fc4f1SJoonyoung Shim 		MXR_STATUS_BURST_MASK);
625cf8fc4f1SJoonyoung Shim 
626cf8fc4f1SJoonyoung Shim 	/* setting default layer priority: layer1 > layer0 > video
627cf8fc4f1SJoonyoung Shim 	 * because typical usage scenario would be
628cf8fc4f1SJoonyoung Shim 	 * layer1 - OSD
629cf8fc4f1SJoonyoung Shim 	 * layer0 - framebuffer
630cf8fc4f1SJoonyoung Shim 	 * video - video overlay
631cf8fc4f1SJoonyoung Shim 	 */
632cf8fc4f1SJoonyoung Shim 	val = MXR_LAYER_CFG_GRP1_VAL(3);
633cf8fc4f1SJoonyoung Shim 	val |= MXR_LAYER_CFG_GRP0_VAL(2);
6341b8e5747SRahul Sharma 	if (ctx->vp_enabled)
635cf8fc4f1SJoonyoung Shim 		val |= MXR_LAYER_CFG_VP_VAL(1);
636cf8fc4f1SJoonyoung Shim 	mixer_reg_write(res, MXR_LAYER_CFG, val);
637cf8fc4f1SJoonyoung Shim 
638cf8fc4f1SJoonyoung Shim 	/* setting background color */
639cf8fc4f1SJoonyoung Shim 	mixer_reg_write(res, MXR_BG_COLOR0, 0x008080);
640cf8fc4f1SJoonyoung Shim 	mixer_reg_write(res, MXR_BG_COLOR1, 0x008080);
641cf8fc4f1SJoonyoung Shim 	mixer_reg_write(res, MXR_BG_COLOR2, 0x008080);
642cf8fc4f1SJoonyoung Shim 
643cf8fc4f1SJoonyoung Shim 	/* setting graphical layers */
644cf8fc4f1SJoonyoung Shim 	val  = MXR_GRP_CFG_COLOR_KEY_DISABLE; /* no blank key */
645cf8fc4f1SJoonyoung Shim 	val |= MXR_GRP_CFG_WIN_BLEND_EN;
6465736603bSSeung-Woo Kim 	val |= MXR_GRP_CFG_BLEND_PRE_MUL;
6475736603bSSeung-Woo Kim 	val |= MXR_GRP_CFG_PIXEL_BLEND_EN;
648cf8fc4f1SJoonyoung Shim 	val |= MXR_GRP_CFG_ALPHA_VAL(0xff); /* non-transparent alpha */
649cf8fc4f1SJoonyoung Shim 
650cf8fc4f1SJoonyoung Shim 	/* the same configuration for both layers */
651cf8fc4f1SJoonyoung Shim 	mixer_reg_write(res, MXR_GRAPHIC_CFG(0), val);
652cf8fc4f1SJoonyoung Shim 	mixer_reg_write(res, MXR_GRAPHIC_CFG(1), val);
653cf8fc4f1SJoonyoung Shim 
6545736603bSSeung-Woo Kim 	/* setting video layers */
6555736603bSSeung-Woo Kim 	val = MXR_GRP_CFG_ALPHA_VAL(0);
6565736603bSSeung-Woo Kim 	mixer_reg_write(res, MXR_VIDEO_CFG, val);
6575736603bSSeung-Woo Kim 
6581b8e5747SRahul Sharma 	if (ctx->vp_enabled) {
659cf8fc4f1SJoonyoung Shim 		/* configuration of Video Processor Registers */
660cf8fc4f1SJoonyoung Shim 		vp_win_reset(ctx);
661cf8fc4f1SJoonyoung Shim 		vp_default_filter(res);
6621b8e5747SRahul Sharma 	}
663cf8fc4f1SJoonyoung Shim 
664cf8fc4f1SJoonyoung Shim 	/* disable all layers */
665cf8fc4f1SJoonyoung Shim 	mixer_reg_writemask(res, MXR_CFG, 0, MXR_CFG_GRP0_ENABLE);
666cf8fc4f1SJoonyoung Shim 	mixer_reg_writemask(res, MXR_CFG, 0, MXR_CFG_GRP1_ENABLE);
6671b8e5747SRahul Sharma 	if (ctx->vp_enabled)
668cf8fc4f1SJoonyoung Shim 		mixer_reg_writemask(res, MXR_CFG, 0, MXR_CFG_VP_ENABLE);
669cf8fc4f1SJoonyoung Shim 
670cf8fc4f1SJoonyoung Shim 	mixer_vsync_set_update(ctx, true);
671cf8fc4f1SJoonyoung Shim 	spin_unlock_irqrestore(&res->reg_slock, flags);
672cf8fc4f1SJoonyoung Shim }
673cf8fc4f1SJoonyoung Shim 
6741055b39fSInki Dae static int mixer_iommu_on(void *ctx, bool enable)
6751055b39fSInki Dae {
6761055b39fSInki Dae 	struct exynos_drm_hdmi_context *drm_hdmi_ctx;
6771055b39fSInki Dae 	struct mixer_context *mdata = ctx;
6781055b39fSInki Dae 	struct drm_device *drm_dev;
6791055b39fSInki Dae 
6801055b39fSInki Dae 	drm_hdmi_ctx = mdata->parent_ctx;
6811055b39fSInki Dae 	drm_dev = drm_hdmi_ctx->drm_dev;
6821055b39fSInki Dae 
6831055b39fSInki Dae 	if (is_drm_iommu_supported(drm_dev)) {
6841055b39fSInki Dae 		if (enable)
6851055b39fSInki Dae 			return drm_iommu_attach_device(drm_dev, mdata->dev);
6861055b39fSInki Dae 
6871055b39fSInki Dae 		drm_iommu_detach_device(drm_dev, mdata->dev);
6881055b39fSInki Dae 	}
6891055b39fSInki Dae 	return 0;
6901055b39fSInki Dae }
6911055b39fSInki Dae 
692d8408326SSeung-Woo Kim static int mixer_enable_vblank(void *ctx, int pipe)
693d8408326SSeung-Woo Kim {
694d8408326SSeung-Woo Kim 	struct mixer_context *mixer_ctx = ctx;
695d8408326SSeung-Woo Kim 	struct mixer_resources *res = &mixer_ctx->mixer_res;
696d8408326SSeung-Woo Kim 
697d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
698d8408326SSeung-Woo Kim 
699d8408326SSeung-Woo Kim 	mixer_ctx->pipe = pipe;
700d8408326SSeung-Woo Kim 
701d8408326SSeung-Woo Kim 	/* enable vsync interrupt */
702d8408326SSeung-Woo Kim 	mixer_reg_writemask(res, MXR_INT_EN, MXR_INT_EN_VSYNC,
703d8408326SSeung-Woo Kim 			MXR_INT_EN_VSYNC);
704d8408326SSeung-Woo Kim 
705d8408326SSeung-Woo Kim 	return 0;
706d8408326SSeung-Woo Kim }
707d8408326SSeung-Woo Kim 
708d8408326SSeung-Woo Kim static void mixer_disable_vblank(void *ctx)
709d8408326SSeung-Woo Kim {
710d8408326SSeung-Woo Kim 	struct mixer_context *mixer_ctx = ctx;
711d8408326SSeung-Woo Kim 	struct mixer_resources *res = &mixer_ctx->mixer_res;
712d8408326SSeung-Woo Kim 
713d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
714d8408326SSeung-Woo Kim 
715d8408326SSeung-Woo Kim 	/* disable vsync interrupt */
716d8408326SSeung-Woo Kim 	mixer_reg_writemask(res, MXR_INT_EN, 0, MXR_INT_EN_VSYNC);
717d8408326SSeung-Woo Kim }
718d8408326SSeung-Woo Kim 
719d8408326SSeung-Woo Kim static void mixer_win_mode_set(void *ctx,
720d8408326SSeung-Woo Kim 			      struct exynos_drm_overlay *overlay)
721d8408326SSeung-Woo Kim {
722d8408326SSeung-Woo Kim 	struct mixer_context *mixer_ctx = ctx;
723d8408326SSeung-Woo Kim 	struct hdmi_win_data *win_data;
724d8408326SSeung-Woo Kim 	int win;
725d8408326SSeung-Woo Kim 
726d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
727d8408326SSeung-Woo Kim 
728d8408326SSeung-Woo Kim 	if (!overlay) {
729d8408326SSeung-Woo Kim 		DRM_ERROR("overlay is NULL\n");
730d8408326SSeung-Woo Kim 		return;
731d8408326SSeung-Woo Kim 	}
732d8408326SSeung-Woo Kim 
733d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS("set [%d]x[%d] at (%d,%d) to [%d]x[%d] at (%d,%d)\n",
734d8408326SSeung-Woo Kim 				 overlay->fb_width, overlay->fb_height,
735d8408326SSeung-Woo Kim 				 overlay->fb_x, overlay->fb_y,
736d8408326SSeung-Woo Kim 				 overlay->crtc_width, overlay->crtc_height,
737d8408326SSeung-Woo Kim 				 overlay->crtc_x, overlay->crtc_y);
738d8408326SSeung-Woo Kim 
739d8408326SSeung-Woo Kim 	win = overlay->zpos;
740d8408326SSeung-Woo Kim 	if (win == DEFAULT_ZPOS)
741a2ee151bSJoonyoung Shim 		win = MIXER_DEFAULT_WIN;
742d8408326SSeung-Woo Kim 
743a634dd54SJoonyoung Shim 	if (win < 0 || win > MIXER_WIN_NR) {
744cf8fc4f1SJoonyoung Shim 		DRM_ERROR("mixer window[%d] is wrong\n", win);
745d8408326SSeung-Woo Kim 		return;
746d8408326SSeung-Woo Kim 	}
747d8408326SSeung-Woo Kim 
748d8408326SSeung-Woo Kim 	win_data = &mixer_ctx->win_data[win];
749d8408326SSeung-Woo Kim 
750d8408326SSeung-Woo Kim 	win_data->dma_addr = overlay->dma_addr[0];
751d8408326SSeung-Woo Kim 	win_data->chroma_dma_addr = overlay->dma_addr[1];
752d8408326SSeung-Woo Kim 	win_data->pixel_format = overlay->pixel_format;
753d8408326SSeung-Woo Kim 	win_data->bpp = overlay->bpp;
754d8408326SSeung-Woo Kim 
755d8408326SSeung-Woo Kim 	win_data->crtc_x = overlay->crtc_x;
756d8408326SSeung-Woo Kim 	win_data->crtc_y = overlay->crtc_y;
757d8408326SSeung-Woo Kim 	win_data->crtc_width = overlay->crtc_width;
758d8408326SSeung-Woo Kim 	win_data->crtc_height = overlay->crtc_height;
759d8408326SSeung-Woo Kim 
760d8408326SSeung-Woo Kim 	win_data->fb_x = overlay->fb_x;
761d8408326SSeung-Woo Kim 	win_data->fb_y = overlay->fb_y;
762d8408326SSeung-Woo Kim 	win_data->fb_width = overlay->fb_width;
763d8408326SSeung-Woo Kim 	win_data->fb_height = overlay->fb_height;
7648dcb96b6SSeung-Woo Kim 	win_data->src_width = overlay->src_width;
7658dcb96b6SSeung-Woo Kim 	win_data->src_height = overlay->src_height;
766d8408326SSeung-Woo Kim 
767d8408326SSeung-Woo Kim 	win_data->mode_width = overlay->mode_width;
768d8408326SSeung-Woo Kim 	win_data->mode_height = overlay->mode_height;
769d8408326SSeung-Woo Kim 
770d8408326SSeung-Woo Kim 	win_data->scan_flags = overlay->scan_flag;
771d8408326SSeung-Woo Kim }
772d8408326SSeung-Woo Kim 
773cf8fc4f1SJoonyoung Shim static void mixer_win_commit(void *ctx, int win)
774d8408326SSeung-Woo Kim {
775d8408326SSeung-Woo Kim 	struct mixer_context *mixer_ctx = ctx;
776d8408326SSeung-Woo Kim 
777d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win);
778d8408326SSeung-Woo Kim 
7791b8e5747SRahul Sharma 	if (win > 1 && mixer_ctx->vp_enabled)
780d8408326SSeung-Woo Kim 		vp_video_buffer(mixer_ctx, win);
781d8408326SSeung-Woo Kim 	else
782d8408326SSeung-Woo Kim 		mixer_graph_buffer(mixer_ctx, win);
783db43fd16SPrathyush K 
784db43fd16SPrathyush K 	mixer_ctx->win_data[win].enabled = true;
785d8408326SSeung-Woo Kim }
786d8408326SSeung-Woo Kim 
787cf8fc4f1SJoonyoung Shim static void mixer_win_disable(void *ctx, int win)
788d8408326SSeung-Woo Kim {
789d8408326SSeung-Woo Kim 	struct mixer_context *mixer_ctx = ctx;
790d8408326SSeung-Woo Kim 	struct mixer_resources *res = &mixer_ctx->mixer_res;
791d8408326SSeung-Woo Kim 	unsigned long flags;
792d8408326SSeung-Woo Kim 
793d8408326SSeung-Woo Kim 	DRM_DEBUG_KMS("[%d] %s, win: %d\n", __LINE__, __func__, win);
794d8408326SSeung-Woo Kim 
795db43fd16SPrathyush K 	mutex_lock(&mixer_ctx->mixer_mutex);
796db43fd16SPrathyush K 	if (!mixer_ctx->powered) {
797db43fd16SPrathyush K 		mutex_unlock(&mixer_ctx->mixer_mutex);
798db43fd16SPrathyush K 		mixer_ctx->win_data[win].resume = false;
799db43fd16SPrathyush K 		return;
800db43fd16SPrathyush K 	}
801db43fd16SPrathyush K 	mutex_unlock(&mixer_ctx->mixer_mutex);
802db43fd16SPrathyush K 
803d8408326SSeung-Woo Kim 	spin_lock_irqsave(&res->reg_slock, flags);
804d8408326SSeung-Woo Kim 	mixer_vsync_set_update(mixer_ctx, false);
805d8408326SSeung-Woo Kim 
806d8408326SSeung-Woo Kim 	mixer_cfg_layer(mixer_ctx, win, false);
807d8408326SSeung-Woo Kim 
808d8408326SSeung-Woo Kim 	mixer_vsync_set_update(mixer_ctx, true);
809d8408326SSeung-Woo Kim 	spin_unlock_irqrestore(&res->reg_slock, flags);
810db43fd16SPrathyush K 
811db43fd16SPrathyush K 	mixer_ctx->win_data[win].enabled = false;
812d8408326SSeung-Woo Kim }
813d8408326SSeung-Woo Kim 
8148137a2e2SPrathyush K static void mixer_wait_for_vblank(void *ctx)
8158137a2e2SPrathyush K {
8168137a2e2SPrathyush K 	struct mixer_context *mixer_ctx = ctx;
8178137a2e2SPrathyush K 
8186e95d5e6SPrathyush K 	mutex_lock(&mixer_ctx->mixer_mutex);
8196e95d5e6SPrathyush K 	if (!mixer_ctx->powered) {
8206e95d5e6SPrathyush K 		mutex_unlock(&mixer_ctx->mixer_mutex);
8216e95d5e6SPrathyush K 		return;
8226e95d5e6SPrathyush K 	}
8236e95d5e6SPrathyush K 	mutex_unlock(&mixer_ctx->mixer_mutex);
8246e95d5e6SPrathyush K 
8256e95d5e6SPrathyush K 	atomic_set(&mixer_ctx->wait_vsync_event, 1);
8266e95d5e6SPrathyush K 
8276e95d5e6SPrathyush K 	/*
8286e95d5e6SPrathyush K 	 * wait for MIXER to signal VSYNC interrupt or return after
8296e95d5e6SPrathyush K 	 * timeout which is set to 50ms (refresh rate of 20).
8306e95d5e6SPrathyush K 	 */
8316e95d5e6SPrathyush K 	if (!wait_event_timeout(mixer_ctx->wait_vsync_queue,
8326e95d5e6SPrathyush K 				!atomic_read(&mixer_ctx->wait_vsync_event),
8336e95d5e6SPrathyush K 				DRM_HZ/20))
8348137a2e2SPrathyush K 		DRM_DEBUG_KMS("vblank wait timed out.\n");
8358137a2e2SPrathyush K }
8368137a2e2SPrathyush K 
837db43fd16SPrathyush K static void mixer_window_suspend(struct mixer_context *ctx)
838db43fd16SPrathyush K {
839db43fd16SPrathyush K 	struct hdmi_win_data *win_data;
840db43fd16SPrathyush K 	int i;
841db43fd16SPrathyush K 
842db43fd16SPrathyush K 	for (i = 0; i < MIXER_WIN_NR; i++) {
843db43fd16SPrathyush K 		win_data = &ctx->win_data[i];
844db43fd16SPrathyush K 		win_data->resume = win_data->enabled;
845db43fd16SPrathyush K 		mixer_win_disable(ctx, i);
846db43fd16SPrathyush K 	}
847db43fd16SPrathyush K 	mixer_wait_for_vblank(ctx);
848db43fd16SPrathyush K }
849db43fd16SPrathyush K 
850db43fd16SPrathyush K static void mixer_window_resume(struct mixer_context *ctx)
851db43fd16SPrathyush K {
852db43fd16SPrathyush K 	struct hdmi_win_data *win_data;
853db43fd16SPrathyush K 	int i;
854db43fd16SPrathyush K 
855db43fd16SPrathyush K 	for (i = 0; i < MIXER_WIN_NR; i++) {
856db43fd16SPrathyush K 		win_data = &ctx->win_data[i];
857db43fd16SPrathyush K 		win_data->enabled = win_data->resume;
858db43fd16SPrathyush K 		win_data->resume = false;
859db43fd16SPrathyush K 	}
860db43fd16SPrathyush K }
861db43fd16SPrathyush K 
862db43fd16SPrathyush K static void mixer_poweron(struct mixer_context *ctx)
863db43fd16SPrathyush K {
864db43fd16SPrathyush K 	struct mixer_resources *res = &ctx->mixer_res;
865db43fd16SPrathyush K 
866db43fd16SPrathyush K 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
867db43fd16SPrathyush K 
868db43fd16SPrathyush K 	mutex_lock(&ctx->mixer_mutex);
869db43fd16SPrathyush K 	if (ctx->powered) {
870db43fd16SPrathyush K 		mutex_unlock(&ctx->mixer_mutex);
871db43fd16SPrathyush K 		return;
872db43fd16SPrathyush K 	}
873db43fd16SPrathyush K 	ctx->powered = true;
874db43fd16SPrathyush K 	mutex_unlock(&ctx->mixer_mutex);
875db43fd16SPrathyush K 
876db43fd16SPrathyush K 	clk_enable(res->mixer);
877db43fd16SPrathyush K 	if (ctx->vp_enabled) {
878db43fd16SPrathyush K 		clk_enable(res->vp);
879db43fd16SPrathyush K 		clk_enable(res->sclk_mixer);
880db43fd16SPrathyush K 	}
881db43fd16SPrathyush K 
882db43fd16SPrathyush K 	mixer_reg_write(res, MXR_INT_EN, ctx->int_en);
883db43fd16SPrathyush K 	mixer_win_reset(ctx);
884db43fd16SPrathyush K 
885db43fd16SPrathyush K 	mixer_window_resume(ctx);
886db43fd16SPrathyush K }
887db43fd16SPrathyush K 
888db43fd16SPrathyush K static void mixer_poweroff(struct mixer_context *ctx)
889db43fd16SPrathyush K {
890db43fd16SPrathyush K 	struct mixer_resources *res = &ctx->mixer_res;
891db43fd16SPrathyush K 
892db43fd16SPrathyush K 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
893db43fd16SPrathyush K 
894db43fd16SPrathyush K 	mutex_lock(&ctx->mixer_mutex);
895db43fd16SPrathyush K 	if (!ctx->powered)
896db43fd16SPrathyush K 		goto out;
897db43fd16SPrathyush K 	mutex_unlock(&ctx->mixer_mutex);
898db43fd16SPrathyush K 
899db43fd16SPrathyush K 	mixer_window_suspend(ctx);
900db43fd16SPrathyush K 
901db43fd16SPrathyush K 	ctx->int_en = mixer_reg_read(res, MXR_INT_EN);
902db43fd16SPrathyush K 
903db43fd16SPrathyush K 	clk_disable(res->mixer);
904db43fd16SPrathyush K 	if (ctx->vp_enabled) {
905db43fd16SPrathyush K 		clk_disable(res->vp);
906db43fd16SPrathyush K 		clk_disable(res->sclk_mixer);
907db43fd16SPrathyush K 	}
908db43fd16SPrathyush K 
909db43fd16SPrathyush K 	mutex_lock(&ctx->mixer_mutex);
910db43fd16SPrathyush K 	ctx->powered = false;
911db43fd16SPrathyush K 
912db43fd16SPrathyush K out:
913db43fd16SPrathyush K 	mutex_unlock(&ctx->mixer_mutex);
914db43fd16SPrathyush K }
915db43fd16SPrathyush K 
916db43fd16SPrathyush K static void mixer_dpms(void *ctx, int mode)
917db43fd16SPrathyush K {
918db43fd16SPrathyush K 	struct mixer_context *mixer_ctx = ctx;
919db43fd16SPrathyush K 
920db43fd16SPrathyush K 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
921db43fd16SPrathyush K 
922db43fd16SPrathyush K 	switch (mode) {
923db43fd16SPrathyush K 	case DRM_MODE_DPMS_ON:
924000f1308SRahul Sharma 		if (pm_runtime_suspended(mixer_ctx->dev))
925000f1308SRahul Sharma 			pm_runtime_get_sync(mixer_ctx->dev);
926db43fd16SPrathyush K 		break;
927db43fd16SPrathyush K 	case DRM_MODE_DPMS_STANDBY:
928db43fd16SPrathyush K 	case DRM_MODE_DPMS_SUSPEND:
929db43fd16SPrathyush K 	case DRM_MODE_DPMS_OFF:
930000f1308SRahul Sharma 		if (!pm_runtime_suspended(mixer_ctx->dev))
931000f1308SRahul Sharma 			pm_runtime_put_sync(mixer_ctx->dev);
932db43fd16SPrathyush K 		break;
933db43fd16SPrathyush K 	default:
934db43fd16SPrathyush K 		DRM_DEBUG_KMS("unknown dpms mode: %d\n", mode);
935db43fd16SPrathyush K 		break;
936db43fd16SPrathyush K 	}
937db43fd16SPrathyush K }
938db43fd16SPrathyush K 
939578b6065SJoonyoung Shim static struct exynos_mixer_ops mixer_ops = {
940578b6065SJoonyoung Shim 	/* manager */
9411055b39fSInki Dae 	.iommu_on		= mixer_iommu_on,
942d8408326SSeung-Woo Kim 	.enable_vblank		= mixer_enable_vblank,
943d8408326SSeung-Woo Kim 	.disable_vblank		= mixer_disable_vblank,
9448137a2e2SPrathyush K 	.wait_for_vblank	= mixer_wait_for_vblank,
945cf8fc4f1SJoonyoung Shim 	.dpms			= mixer_dpms,
946578b6065SJoonyoung Shim 
947578b6065SJoonyoung Shim 	/* overlay */
948d8408326SSeung-Woo Kim 	.win_mode_set		= mixer_win_mode_set,
949d8408326SSeung-Woo Kim 	.win_commit		= mixer_win_commit,
950d8408326SSeung-Woo Kim 	.win_disable		= mixer_win_disable,
951d8408326SSeung-Woo Kim };
952d8408326SSeung-Woo Kim 
953d8408326SSeung-Woo Kim static irqreturn_t mixer_irq_handler(int irq, void *arg)
954d8408326SSeung-Woo Kim {
955d8408326SSeung-Woo Kim 	struct exynos_drm_hdmi_context *drm_hdmi_ctx = arg;
956f9309d1bSJoonyoung Shim 	struct mixer_context *ctx = drm_hdmi_ctx->ctx;
957d8408326SSeung-Woo Kim 	struct mixer_resources *res = &ctx->mixer_res;
9588379e482SSeung-Woo Kim 	u32 val, base, shadow;
959d8408326SSeung-Woo Kim 
960d8408326SSeung-Woo Kim 	spin_lock(&res->reg_slock);
961d8408326SSeung-Woo Kim 
962d8408326SSeung-Woo Kim 	/* read interrupt status for handling and clearing flags for VSYNC */
963d8408326SSeung-Woo Kim 	val = mixer_reg_read(res, MXR_INT_STATUS);
964d8408326SSeung-Woo Kim 
965d8408326SSeung-Woo Kim 	/* handling VSYNC */
966d8408326SSeung-Woo Kim 	if (val & MXR_INT_STATUS_VSYNC) {
967d8408326SSeung-Woo Kim 		/* interlace scan need to check shadow register */
968d8408326SSeung-Woo Kim 		if (ctx->interlace) {
9698379e482SSeung-Woo Kim 			base = mixer_reg_read(res, MXR_GRAPHIC_BASE(0));
9708379e482SSeung-Woo Kim 			shadow = mixer_reg_read(res, MXR_GRAPHIC_BASE_S(0));
9718379e482SSeung-Woo Kim 			if (base != shadow)
972d8408326SSeung-Woo Kim 				goto out;
973d8408326SSeung-Woo Kim 
9748379e482SSeung-Woo Kim 			base = mixer_reg_read(res, MXR_GRAPHIC_BASE(1));
9758379e482SSeung-Woo Kim 			shadow = mixer_reg_read(res, MXR_GRAPHIC_BASE_S(1));
9768379e482SSeung-Woo Kim 			if (base != shadow)
977d8408326SSeung-Woo Kim 				goto out;
978d8408326SSeung-Woo Kim 		}
979d8408326SSeung-Woo Kim 
980d8408326SSeung-Woo Kim 		drm_handle_vblank(drm_hdmi_ctx->drm_dev, ctx->pipe);
981*663d8766SRahul Sharma 		exynos_drm_crtc_finish_pageflip(drm_hdmi_ctx->drm_dev,
982*663d8766SRahul Sharma 				ctx->pipe);
9836e95d5e6SPrathyush K 
9846e95d5e6SPrathyush K 		/* set wait vsync event to zero and wake up queue. */
9856e95d5e6SPrathyush K 		if (atomic_read(&ctx->wait_vsync_event)) {
9866e95d5e6SPrathyush K 			atomic_set(&ctx->wait_vsync_event, 0);
9876e95d5e6SPrathyush K 			DRM_WAKEUP(&ctx->wait_vsync_queue);
9886e95d5e6SPrathyush K 		}
989d8408326SSeung-Woo Kim 	}
990d8408326SSeung-Woo Kim 
991d8408326SSeung-Woo Kim out:
992d8408326SSeung-Woo Kim 	/* clear interrupts */
993d8408326SSeung-Woo Kim 	if (~val & MXR_INT_EN_VSYNC) {
994d8408326SSeung-Woo Kim 		/* vsync interrupt use different bit for read and clear */
995d8408326SSeung-Woo Kim 		val &= ~MXR_INT_EN_VSYNC;
996d8408326SSeung-Woo Kim 		val |= MXR_INT_CLEAR_VSYNC;
997d8408326SSeung-Woo Kim 	}
998d8408326SSeung-Woo Kim 	mixer_reg_write(res, MXR_INT_STATUS, val);
999d8408326SSeung-Woo Kim 
1000d8408326SSeung-Woo Kim 	spin_unlock(&res->reg_slock);
1001d8408326SSeung-Woo Kim 
1002d8408326SSeung-Woo Kim 	return IRQ_HANDLED;
1003d8408326SSeung-Woo Kim }
1004d8408326SSeung-Woo Kim 
1005d8408326SSeung-Woo Kim static int __devinit mixer_resources_init(struct exynos_drm_hdmi_context *ctx,
1006d8408326SSeung-Woo Kim 				 struct platform_device *pdev)
1007d8408326SSeung-Woo Kim {
1008f9309d1bSJoonyoung Shim 	struct mixer_context *mixer_ctx = ctx->ctx;
1009d8408326SSeung-Woo Kim 	struct device *dev = &pdev->dev;
1010d8408326SSeung-Woo Kim 	struct mixer_resources *mixer_res = &mixer_ctx->mixer_res;
1011d8408326SSeung-Woo Kim 	struct resource *res;
1012d8408326SSeung-Woo Kim 	int ret;
1013d8408326SSeung-Woo Kim 
1014d8408326SSeung-Woo Kim 	spin_lock_init(&mixer_res->reg_slock);
1015d8408326SSeung-Woo Kim 
101637f50861SSachin Kamat 	mixer_res->mixer = devm_clk_get(dev, "mixer");
1017d8408326SSeung-Woo Kim 	if (IS_ERR_OR_NULL(mixer_res->mixer)) {
1018d8408326SSeung-Woo Kim 		dev_err(dev, "failed to get clock 'mixer'\n");
101937f50861SSachin Kamat 		return -ENODEV;
1020d8408326SSeung-Woo Kim 	}
10211b8e5747SRahul Sharma 
102237f50861SSachin Kamat 	mixer_res->sclk_hdmi = devm_clk_get(dev, "sclk_hdmi");
1023d8408326SSeung-Woo Kim 	if (IS_ERR_OR_NULL(mixer_res->sclk_hdmi)) {
1024d8408326SSeung-Woo Kim 		dev_err(dev, "failed to get clock 'sclk_hdmi'\n");
102537f50861SSachin Kamat 		return -ENODEV;
1026d8408326SSeung-Woo Kim 	}
10271b8e5747SRahul Sharma 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1028d8408326SSeung-Woo Kim 	if (res == NULL) {
1029d8408326SSeung-Woo Kim 		dev_err(dev, "get memory resource failed.\n");
103037f50861SSachin Kamat 		return -ENXIO;
1031d8408326SSeung-Woo Kim 	}
1032d8408326SSeung-Woo Kim 
10339416dfa7SSachin Kamat 	mixer_res->mixer_regs = devm_ioremap(&pdev->dev, res->start,
10349416dfa7SSachin Kamat 							resource_size(res));
1035d8408326SSeung-Woo Kim 	if (mixer_res->mixer_regs == NULL) {
1036d8408326SSeung-Woo Kim 		dev_err(dev, "register mapping failed.\n");
103737f50861SSachin Kamat 		return -ENXIO;
1038d8408326SSeung-Woo Kim 	}
1039d8408326SSeung-Woo Kim 
10401b8e5747SRahul Sharma 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1041d8408326SSeung-Woo Kim 	if (res == NULL) {
1042d8408326SSeung-Woo Kim 		dev_err(dev, "get interrupt resource failed.\n");
104337f50861SSachin Kamat 		return -ENXIO;
1044d8408326SSeung-Woo Kim 	}
1045d8408326SSeung-Woo Kim 
10469416dfa7SSachin Kamat 	ret = devm_request_irq(&pdev->dev, res->start, mixer_irq_handler,
10479416dfa7SSachin Kamat 							0, "drm_mixer", ctx);
1048d8408326SSeung-Woo Kim 	if (ret) {
1049d8408326SSeung-Woo Kim 		dev_err(dev, "request interrupt failed.\n");
105037f50861SSachin Kamat 		return ret;
1051d8408326SSeung-Woo Kim 	}
1052d8408326SSeung-Woo Kim 	mixer_res->irq = res->start;
1053d8408326SSeung-Woo Kim 
1054d8408326SSeung-Woo Kim 	return 0;
1055d8408326SSeung-Woo Kim }
1056d8408326SSeung-Woo Kim 
10571b8e5747SRahul Sharma static int __devinit vp_resources_init(struct exynos_drm_hdmi_context *ctx,
10581b8e5747SRahul Sharma 				 struct platform_device *pdev)
10591b8e5747SRahul Sharma {
10601b8e5747SRahul Sharma 	struct mixer_context *mixer_ctx = ctx->ctx;
10611b8e5747SRahul Sharma 	struct device *dev = &pdev->dev;
10621b8e5747SRahul Sharma 	struct mixer_resources *mixer_res = &mixer_ctx->mixer_res;
10631b8e5747SRahul Sharma 	struct resource *res;
10641b8e5747SRahul Sharma 
106537f50861SSachin Kamat 	mixer_res->vp = devm_clk_get(dev, "vp");
10661b8e5747SRahul Sharma 	if (IS_ERR_OR_NULL(mixer_res->vp)) {
10671b8e5747SRahul Sharma 		dev_err(dev, "failed to get clock 'vp'\n");
106837f50861SSachin Kamat 		return -ENODEV;
10691b8e5747SRahul Sharma 	}
107037f50861SSachin Kamat 	mixer_res->sclk_mixer = devm_clk_get(dev, "sclk_mixer");
10711b8e5747SRahul Sharma 	if (IS_ERR_OR_NULL(mixer_res->sclk_mixer)) {
10721b8e5747SRahul Sharma 		dev_err(dev, "failed to get clock 'sclk_mixer'\n");
107337f50861SSachin Kamat 		return -ENODEV;
10741b8e5747SRahul Sharma 	}
107537f50861SSachin Kamat 	mixer_res->sclk_dac = devm_clk_get(dev, "sclk_dac");
10761b8e5747SRahul Sharma 	if (IS_ERR_OR_NULL(mixer_res->sclk_dac)) {
10771b8e5747SRahul Sharma 		dev_err(dev, "failed to get clock 'sclk_dac'\n");
107837f50861SSachin Kamat 		return -ENODEV;
10791b8e5747SRahul Sharma 	}
10801b8e5747SRahul Sharma 
10811b8e5747SRahul Sharma 	if (mixer_res->sclk_hdmi)
10821b8e5747SRahul Sharma 		clk_set_parent(mixer_res->sclk_mixer, mixer_res->sclk_hdmi);
10831b8e5747SRahul Sharma 
10841b8e5747SRahul Sharma 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
10851b8e5747SRahul Sharma 	if (res == NULL) {
10861b8e5747SRahul Sharma 		dev_err(dev, "get memory resource failed.\n");
108737f50861SSachin Kamat 		return -ENXIO;
10881b8e5747SRahul Sharma 	}
10891b8e5747SRahul Sharma 
10901b8e5747SRahul Sharma 	mixer_res->vp_regs = devm_ioremap(&pdev->dev, res->start,
10911b8e5747SRahul Sharma 							resource_size(res));
10921b8e5747SRahul Sharma 	if (mixer_res->vp_regs == NULL) {
10931b8e5747SRahul Sharma 		dev_err(dev, "register mapping failed.\n");
109437f50861SSachin Kamat 		return -ENXIO;
10951b8e5747SRahul Sharma 	}
10961b8e5747SRahul Sharma 
10971b8e5747SRahul Sharma 	return 0;
10981b8e5747SRahul Sharma }
10991b8e5747SRahul Sharma 
1100aaf8b49eSRahul Sharma static struct mixer_drv_data exynos5_mxr_drv_data = {
1101aaf8b49eSRahul Sharma 	.version = MXR_VER_16_0_33_0,
1102aaf8b49eSRahul Sharma 	.is_vp_enabled = 0,
1103aaf8b49eSRahul Sharma };
1104aaf8b49eSRahul Sharma 
11051e123441SRahul Sharma static struct mixer_drv_data exynos4_mxr_drv_data = {
11061e123441SRahul Sharma 	.version = MXR_VER_0_0_0_16,
11071b8e5747SRahul Sharma 	.is_vp_enabled = 1,
11081e123441SRahul Sharma };
11091e123441SRahul Sharma 
11101e123441SRahul Sharma static struct platform_device_id mixer_driver_types[] = {
11111e123441SRahul Sharma 	{
11121e123441SRahul Sharma 		.name		= "s5p-mixer",
11131e123441SRahul Sharma 		.driver_data	= (unsigned long)&exynos4_mxr_drv_data,
11141e123441SRahul Sharma 	}, {
1115aaf8b49eSRahul Sharma 		.name		= "exynos5-mixer",
1116aaf8b49eSRahul Sharma 		.driver_data	= (unsigned long)&exynos5_mxr_drv_data,
1117aaf8b49eSRahul Sharma 	}, {
1118aaf8b49eSRahul Sharma 		/* end node */
1119aaf8b49eSRahul Sharma 	}
1120aaf8b49eSRahul Sharma };
1121aaf8b49eSRahul Sharma 
1122aaf8b49eSRahul Sharma static struct of_device_id mixer_match_types[] = {
1123aaf8b49eSRahul Sharma 	{
1124aaf8b49eSRahul Sharma 		.compatible = "samsung,exynos5-mixer",
1125aaf8b49eSRahul Sharma 		.data	= &exynos5_mxr_drv_data,
1126aaf8b49eSRahul Sharma 	}, {
11271e123441SRahul Sharma 		/* end node */
11281e123441SRahul Sharma 	}
11291e123441SRahul Sharma };
11301e123441SRahul Sharma 
1131d8408326SSeung-Woo Kim static int __devinit mixer_probe(struct platform_device *pdev)
1132d8408326SSeung-Woo Kim {
1133d8408326SSeung-Woo Kim 	struct device *dev = &pdev->dev;
1134d8408326SSeung-Woo Kim 	struct exynos_drm_hdmi_context *drm_hdmi_ctx;
1135d8408326SSeung-Woo Kim 	struct mixer_context *ctx;
11361e123441SRahul Sharma 	struct mixer_drv_data *drv;
1137d8408326SSeung-Woo Kim 	int ret;
1138d8408326SSeung-Woo Kim 
1139d8408326SSeung-Woo Kim 	dev_info(dev, "probe start\n");
1140d8408326SSeung-Woo Kim 
11419416dfa7SSachin Kamat 	drm_hdmi_ctx = devm_kzalloc(&pdev->dev, sizeof(*drm_hdmi_ctx),
11429416dfa7SSachin Kamat 								GFP_KERNEL);
1143d8408326SSeung-Woo Kim 	if (!drm_hdmi_ctx) {
1144d8408326SSeung-Woo Kim 		DRM_ERROR("failed to allocate common hdmi context.\n");
1145d8408326SSeung-Woo Kim 		return -ENOMEM;
1146d8408326SSeung-Woo Kim 	}
1147d8408326SSeung-Woo Kim 
11489416dfa7SSachin Kamat 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
1149d8408326SSeung-Woo Kim 	if (!ctx) {
1150d8408326SSeung-Woo Kim 		DRM_ERROR("failed to alloc mixer context.\n");
1151d8408326SSeung-Woo Kim 		return -ENOMEM;
1152d8408326SSeung-Woo Kim 	}
1153d8408326SSeung-Woo Kim 
1154cf8fc4f1SJoonyoung Shim 	mutex_init(&ctx->mixer_mutex);
1155cf8fc4f1SJoonyoung Shim 
1156aaf8b49eSRahul Sharma 	if (dev->of_node) {
1157aaf8b49eSRahul Sharma 		const struct of_device_id *match;
1158aaf8b49eSRahul Sharma 		match = of_match_node(of_match_ptr(mixer_match_types),
1159aaf8b49eSRahul Sharma 							  pdev->dev.of_node);
11602cdc53b3SRahul Sharma 		drv = (struct mixer_drv_data *)match->data;
1161aaf8b49eSRahul Sharma 	} else {
1162aaf8b49eSRahul Sharma 		drv = (struct mixer_drv_data *)
1163aaf8b49eSRahul Sharma 			platform_get_device_id(pdev)->driver_data;
1164aaf8b49eSRahul Sharma 	}
1165aaf8b49eSRahul Sharma 
1166cf8fc4f1SJoonyoung Shim 	ctx->dev = &pdev->dev;
11671055b39fSInki Dae 	ctx->parent_ctx = (void *)drm_hdmi_ctx;
1168d8408326SSeung-Woo Kim 	drm_hdmi_ctx->ctx = (void *)ctx;
11691b8e5747SRahul Sharma 	ctx->vp_enabled = drv->is_vp_enabled;
11701e123441SRahul Sharma 	ctx->mxr_ver = drv->version;
11716e95d5e6SPrathyush K 	DRM_INIT_WAITQUEUE(&ctx->wait_vsync_queue);
11726e95d5e6SPrathyush K 	atomic_set(&ctx->wait_vsync_event, 0);
1173d8408326SSeung-Woo Kim 
1174d8408326SSeung-Woo Kim 	platform_set_drvdata(pdev, drm_hdmi_ctx);
1175d8408326SSeung-Woo Kim 
1176d8408326SSeung-Woo Kim 	/* acquire resources: regs, irqs, clocks */
1177d8408326SSeung-Woo Kim 	ret = mixer_resources_init(drm_hdmi_ctx, pdev);
11781b8e5747SRahul Sharma 	if (ret) {
11791b8e5747SRahul Sharma 		DRM_ERROR("mixer_resources_init failed\n");
1180d8408326SSeung-Woo Kim 		goto fail;
11811b8e5747SRahul Sharma 	}
11821b8e5747SRahul Sharma 
11831b8e5747SRahul Sharma 	if (ctx->vp_enabled) {
11841b8e5747SRahul Sharma 		/* acquire vp resources: regs, irqs, clocks */
11851b8e5747SRahul Sharma 		ret = vp_resources_init(drm_hdmi_ctx, pdev);
11861b8e5747SRahul Sharma 		if (ret) {
11871b8e5747SRahul Sharma 			DRM_ERROR("vp_resources_init failed\n");
11881b8e5747SRahul Sharma 			goto fail;
11891b8e5747SRahul Sharma 		}
11901b8e5747SRahul Sharma 	}
1191d8408326SSeung-Woo Kim 
1192768c3059SRahul Sharma 	/* attach mixer driver to common hdmi. */
1193768c3059SRahul Sharma 	exynos_mixer_drv_attach(drm_hdmi_ctx);
1194d8408326SSeung-Woo Kim 
1195d8408326SSeung-Woo Kim 	/* register specific callback point to common hdmi. */
1196578b6065SJoonyoung Shim 	exynos_mixer_ops_register(&mixer_ops);
1197d8408326SSeung-Woo Kim 
1198cf8fc4f1SJoonyoung Shim 	pm_runtime_enable(dev);
1199d8408326SSeung-Woo Kim 
1200d8408326SSeung-Woo Kim 	return 0;
1201d8408326SSeung-Woo Kim 
1202d8408326SSeung-Woo Kim 
1203d8408326SSeung-Woo Kim fail:
1204d8408326SSeung-Woo Kim 	dev_info(dev, "probe failed\n");
1205d8408326SSeung-Woo Kim 	return ret;
1206d8408326SSeung-Woo Kim }
1207d8408326SSeung-Woo Kim 
1208d8408326SSeung-Woo Kim static int mixer_remove(struct platform_device *pdev)
1209d8408326SSeung-Woo Kim {
12109416dfa7SSachin Kamat 	dev_info(&pdev->dev, "remove successful\n");
1211d8408326SSeung-Woo Kim 
1212cf8fc4f1SJoonyoung Shim 	pm_runtime_disable(&pdev->dev);
1213cf8fc4f1SJoonyoung Shim 
1214d8408326SSeung-Woo Kim 	return 0;
1215d8408326SSeung-Woo Kim }
1216d8408326SSeung-Woo Kim 
1217ab27af85SJoonyoung Shim #ifdef CONFIG_PM_SLEEP
1218ab27af85SJoonyoung Shim static int mixer_suspend(struct device *dev)
1219ab27af85SJoonyoung Shim {
1220ab27af85SJoonyoung Shim 	struct exynos_drm_hdmi_context *drm_hdmi_ctx = get_mixer_context(dev);
1221ab27af85SJoonyoung Shim 	struct mixer_context *ctx = drm_hdmi_ctx->ctx;
1222ab27af85SJoonyoung Shim 
1223000f1308SRahul Sharma 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1224000f1308SRahul Sharma 
1225000f1308SRahul Sharma 	if (pm_runtime_suspended(dev)) {
1226000f1308SRahul Sharma 		DRM_DEBUG_KMS("%s : Already suspended\n", __func__);
1227000f1308SRahul Sharma 		return 0;
1228000f1308SRahul Sharma 	}
1229000f1308SRahul Sharma 
1230ab27af85SJoonyoung Shim 	mixer_poweroff(ctx);
1231ab27af85SJoonyoung Shim 
1232ab27af85SJoonyoung Shim 	return 0;
1233ab27af85SJoonyoung Shim }
1234000f1308SRahul Sharma 
1235000f1308SRahul Sharma static int mixer_resume(struct device *dev)
1236000f1308SRahul Sharma {
1237000f1308SRahul Sharma 	struct exynos_drm_hdmi_context *drm_hdmi_ctx = get_mixer_context(dev);
1238000f1308SRahul Sharma 	struct mixer_context *ctx = drm_hdmi_ctx->ctx;
1239000f1308SRahul Sharma 
1240000f1308SRahul Sharma 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1241000f1308SRahul Sharma 
1242000f1308SRahul Sharma 	if (!pm_runtime_suspended(dev)) {
1243000f1308SRahul Sharma 		DRM_DEBUG_KMS("%s : Already resumed\n", __func__);
1244000f1308SRahul Sharma 		return 0;
1245000f1308SRahul Sharma 	}
1246000f1308SRahul Sharma 
1247000f1308SRahul Sharma 	mixer_poweron(ctx);
1248000f1308SRahul Sharma 
1249000f1308SRahul Sharma 	return 0;
1250000f1308SRahul Sharma }
1251ab27af85SJoonyoung Shim #endif
1252ab27af85SJoonyoung Shim 
1253000f1308SRahul Sharma #ifdef CONFIG_PM_RUNTIME
1254000f1308SRahul Sharma static int mixer_runtime_suspend(struct device *dev)
1255000f1308SRahul Sharma {
1256000f1308SRahul Sharma 	struct exynos_drm_hdmi_context *drm_hdmi_ctx = get_mixer_context(dev);
1257000f1308SRahul Sharma 	struct mixer_context *ctx = drm_hdmi_ctx->ctx;
1258000f1308SRahul Sharma 
1259000f1308SRahul Sharma 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1260000f1308SRahul Sharma 
1261000f1308SRahul Sharma 	mixer_poweroff(ctx);
1262000f1308SRahul Sharma 
1263000f1308SRahul Sharma 	return 0;
1264000f1308SRahul Sharma }
1265000f1308SRahul Sharma 
1266000f1308SRahul Sharma static int mixer_runtime_resume(struct device *dev)
1267000f1308SRahul Sharma {
1268000f1308SRahul Sharma 	struct exynos_drm_hdmi_context *drm_hdmi_ctx = get_mixer_context(dev);
1269000f1308SRahul Sharma 	struct mixer_context *ctx = drm_hdmi_ctx->ctx;
1270000f1308SRahul Sharma 
1271000f1308SRahul Sharma 	DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__);
1272000f1308SRahul Sharma 
1273000f1308SRahul Sharma 	mixer_poweron(ctx);
1274000f1308SRahul Sharma 
1275000f1308SRahul Sharma 	return 0;
1276000f1308SRahul Sharma }
1277000f1308SRahul Sharma #endif
1278000f1308SRahul Sharma 
1279000f1308SRahul Sharma static const struct dev_pm_ops mixer_pm_ops = {
1280000f1308SRahul Sharma 	SET_SYSTEM_SLEEP_PM_OPS(mixer_suspend, mixer_resume)
1281000f1308SRahul Sharma 	SET_RUNTIME_PM_OPS(mixer_runtime_suspend, mixer_runtime_resume, NULL)
1282000f1308SRahul Sharma };
1283ab27af85SJoonyoung Shim 
1284d8408326SSeung-Woo Kim struct platform_driver mixer_driver = {
1285d8408326SSeung-Woo Kim 	.driver = {
1286aaf8b49eSRahul Sharma 		.name = "exynos-mixer",
1287d8408326SSeung-Woo Kim 		.owner = THIS_MODULE,
1288ab27af85SJoonyoung Shim 		.pm = &mixer_pm_ops,
1289aaf8b49eSRahul Sharma 		.of_match_table = mixer_match_types,
1290d8408326SSeung-Woo Kim 	},
1291d8408326SSeung-Woo Kim 	.probe = mixer_probe,
1292d8408326SSeung-Woo Kim 	.remove = __devexit_p(mixer_remove),
12931e123441SRahul Sharma 	.id_table	= mixer_driver_types,
1294d8408326SSeung-Woo Kim };
1295