18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright © 2010 Intel Corporation
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next
128c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
138c2ecf20Sopenharmony_ci * Software.
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
178c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
188c2ecf20Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
198c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
208c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
218c2ecf20Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
228c2ecf20Sopenharmony_ci *
238c2ecf20Sopenharmony_ci * Authors:
248c2ecf20Sopenharmony_ci * jim liu <jim.liu@intel.com>
258c2ecf20Sopenharmony_ci * Jackie Li<yaodong.li@intel.com>
268c2ecf20Sopenharmony_ci */
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#ifndef __MDFLD_DSI_OUTPUT_H__
298c2ecf20Sopenharmony_ci#define __MDFLD_DSI_OUTPUT_H__
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#include <linux/backlight.h>
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#include <asm/intel-mid.h>
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#include <drm/drm.h>
368c2ecf20Sopenharmony_ci#include <drm/drm_crtc.h>
378c2ecf20Sopenharmony_ci#include <drm/drm_edid.h>
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#include "mdfld_output.h"
408c2ecf20Sopenharmony_ci#include "psb_drv.h"
418c2ecf20Sopenharmony_ci#include "psb_intel_drv.h"
428c2ecf20Sopenharmony_ci#include "psb_intel_reg.h"
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define FLD_MASK(start, end)	(((1 << ((start) - (end) + 1)) - 1) << (end))
458c2ecf20Sopenharmony_ci#define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end))
468c2ecf20Sopenharmony_ci#define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end))
478c2ecf20Sopenharmony_ci#define FLD_MOD(orig, val, start, end) \
488c2ecf20Sopenharmony_ci	(((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define REG_FLD_MOD(reg, val, start, end) \
518c2ecf20Sopenharmony_ci	REG_WRITE(reg, FLD_MOD(REG_READ(reg), val, start, end))
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_cistatic inline int REGISTER_FLD_WAIT(struct drm_device *dev, u32 reg,
548c2ecf20Sopenharmony_ci		u32 val, int start, int end)
558c2ecf20Sopenharmony_ci{
568c2ecf20Sopenharmony_ci	int t = 100000;
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	while (FLD_GET(REG_READ(reg), start, end) != val) {
598c2ecf20Sopenharmony_ci		if (--t == 0)
608c2ecf20Sopenharmony_ci			return 1;
618c2ecf20Sopenharmony_ci	}
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	return 0;
648c2ecf20Sopenharmony_ci}
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define REG_FLD_WAIT(reg, val, start, end) \
678c2ecf20Sopenharmony_ci	REGISTER_FLD_WAIT(dev, reg, val, start, end)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci#define REG_BIT_WAIT(reg, val, bitnum) \
708c2ecf20Sopenharmony_ci	REGISTER_FLD_WAIT(dev, reg, val, bitnum, bitnum)
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#define MDFLD_DSI_BRIGHTNESS_MAX_LEVEL 100
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci#ifdef DEBUG
758c2ecf20Sopenharmony_ci#define CHECK_PIPE(pipe) ({			\
768c2ecf20Sopenharmony_ci	const typeof(pipe) __pipe = (pipe);	\
778c2ecf20Sopenharmony_ci	BUG_ON(__pipe != 0 && __pipe != 2);	\
788c2ecf20Sopenharmony_ci	__pipe;	})
798c2ecf20Sopenharmony_ci#else
808c2ecf20Sopenharmony_ci#define CHECK_PIPE(pipe) (pipe)
818c2ecf20Sopenharmony_ci#endif
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/*
848c2ecf20Sopenharmony_ci * Actual MIPIA->MIPIC reg offset is 0x800, value 0x400 is valid for 0 and 2
858c2ecf20Sopenharmony_ci */
868c2ecf20Sopenharmony_ci#define REG_OFFSET(pipe) (CHECK_PIPE(pipe) * 0x400)
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci/* mdfld DSI controller registers */
898c2ecf20Sopenharmony_ci#define MIPI_DEVICE_READY_REG(pipe)		(0xb000 + REG_OFFSET(pipe))
908c2ecf20Sopenharmony_ci#define MIPI_INTR_STAT_REG(pipe)		(0xb004 + REG_OFFSET(pipe))
918c2ecf20Sopenharmony_ci#define MIPI_INTR_EN_REG(pipe)			(0xb008 + REG_OFFSET(pipe))
928c2ecf20Sopenharmony_ci#define MIPI_DSI_FUNC_PRG_REG(pipe)		(0xb00c + REG_OFFSET(pipe))
938c2ecf20Sopenharmony_ci#define MIPI_HS_TX_TIMEOUT_REG(pipe)		(0xb010 + REG_OFFSET(pipe))
948c2ecf20Sopenharmony_ci#define MIPI_LP_RX_TIMEOUT_REG(pipe)		(0xb014 + REG_OFFSET(pipe))
958c2ecf20Sopenharmony_ci#define MIPI_TURN_AROUND_TIMEOUT_REG(pipe)	(0xb018 + REG_OFFSET(pipe))
968c2ecf20Sopenharmony_ci#define MIPI_DEVICE_RESET_TIMER_REG(pipe)	(0xb01c + REG_OFFSET(pipe))
978c2ecf20Sopenharmony_ci#define MIPI_DPI_RESOLUTION_REG(pipe)		(0xb020 + REG_OFFSET(pipe))
988c2ecf20Sopenharmony_ci#define MIPI_DBI_FIFO_THROTTLE_REG(pipe)	(0xb024 + REG_OFFSET(pipe))
998c2ecf20Sopenharmony_ci#define MIPI_HSYNC_COUNT_REG(pipe)		(0xb028 + REG_OFFSET(pipe))
1008c2ecf20Sopenharmony_ci#define MIPI_HBP_COUNT_REG(pipe)		(0xb02c + REG_OFFSET(pipe))
1018c2ecf20Sopenharmony_ci#define MIPI_HFP_COUNT_REG(pipe)		(0xb030 + REG_OFFSET(pipe))
1028c2ecf20Sopenharmony_ci#define MIPI_HACTIVE_COUNT_REG(pipe)		(0xb034 + REG_OFFSET(pipe))
1038c2ecf20Sopenharmony_ci#define MIPI_VSYNC_COUNT_REG(pipe)		(0xb038 + REG_OFFSET(pipe))
1048c2ecf20Sopenharmony_ci#define MIPI_VBP_COUNT_REG(pipe)		(0xb03c + REG_OFFSET(pipe))
1058c2ecf20Sopenharmony_ci#define MIPI_VFP_COUNT_REG(pipe)		(0xb040 + REG_OFFSET(pipe))
1068c2ecf20Sopenharmony_ci#define MIPI_HIGH_LOW_SWITCH_COUNT_REG(pipe)	(0xb044 + REG_OFFSET(pipe))
1078c2ecf20Sopenharmony_ci#define MIPI_DPI_CONTROL_REG(pipe)		(0xb048 + REG_OFFSET(pipe))
1088c2ecf20Sopenharmony_ci#define MIPI_DPI_DATA_REG(pipe)			(0xb04c + REG_OFFSET(pipe))
1098c2ecf20Sopenharmony_ci#define MIPI_INIT_COUNT_REG(pipe)		(0xb050 + REG_OFFSET(pipe))
1108c2ecf20Sopenharmony_ci#define MIPI_MAX_RETURN_PACK_SIZE_REG(pipe)	(0xb054 + REG_OFFSET(pipe))
1118c2ecf20Sopenharmony_ci#define MIPI_VIDEO_MODE_FORMAT_REG(pipe)	(0xb058 + REG_OFFSET(pipe))
1128c2ecf20Sopenharmony_ci#define MIPI_EOT_DISABLE_REG(pipe)		(0xb05c + REG_OFFSET(pipe))
1138c2ecf20Sopenharmony_ci#define MIPI_LP_BYTECLK_REG(pipe)		(0xb060 + REG_OFFSET(pipe))
1148c2ecf20Sopenharmony_ci#define MIPI_LP_GEN_DATA_REG(pipe)		(0xb064 + REG_OFFSET(pipe))
1158c2ecf20Sopenharmony_ci#define MIPI_HS_GEN_DATA_REG(pipe)		(0xb068 + REG_OFFSET(pipe))
1168c2ecf20Sopenharmony_ci#define MIPI_LP_GEN_CTRL_REG(pipe)		(0xb06c + REG_OFFSET(pipe))
1178c2ecf20Sopenharmony_ci#define MIPI_HS_GEN_CTRL_REG(pipe)		(0xb070 + REG_OFFSET(pipe))
1188c2ecf20Sopenharmony_ci#define MIPI_GEN_FIFO_STAT_REG(pipe)		(0xb074 + REG_OFFSET(pipe))
1198c2ecf20Sopenharmony_ci#define MIPI_HS_LS_DBI_ENABLE_REG(pipe)		(0xb078 + REG_OFFSET(pipe))
1208c2ecf20Sopenharmony_ci#define MIPI_DPHY_PARAM_REG(pipe)		(0xb080 + REG_OFFSET(pipe))
1218c2ecf20Sopenharmony_ci#define MIPI_DBI_BW_CTRL_REG(pipe)		(0xb084 + REG_OFFSET(pipe))
1228c2ecf20Sopenharmony_ci#define MIPI_CLK_LANE_SWITCH_TIME_CNT_REG(pipe)	(0xb088 + REG_OFFSET(pipe))
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define MIPI_CTRL_REG(pipe)			(0xb104 + REG_OFFSET(pipe))
1258c2ecf20Sopenharmony_ci#define MIPI_DATA_ADD_REG(pipe)			(0xb108 + REG_OFFSET(pipe))
1268c2ecf20Sopenharmony_ci#define MIPI_DATA_LEN_REG(pipe)			(0xb10c + REG_OFFSET(pipe))
1278c2ecf20Sopenharmony_ci#define MIPI_CMD_ADD_REG(pipe)			(0xb110 + REG_OFFSET(pipe))
1288c2ecf20Sopenharmony_ci#define MIPI_CMD_LEN_REG(pipe)			(0xb114 + REG_OFFSET(pipe))
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci/* non-uniform reg offset */
1318c2ecf20Sopenharmony_ci#define MIPI_PORT_CONTROL(pipe)		(CHECK_PIPE(pipe) ? MIPI_C : MIPI)
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define DSI_DEVICE_READY				(0x1)
1348c2ecf20Sopenharmony_ci#define DSI_POWER_STATE_ULPS_ENTER			(0x2 << 1)
1358c2ecf20Sopenharmony_ci#define DSI_POWER_STATE_ULPS_EXIT			(0x1 << 1)
1368c2ecf20Sopenharmony_ci#define DSI_POWER_STATE_ULPS_OFFSET			(0x1)
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci#define DSI_ONE_DATA_LANE					(0x1)
1408c2ecf20Sopenharmony_ci#define DSI_TWO_DATA_LANE					(0x2)
1418c2ecf20Sopenharmony_ci#define DSI_THREE_DATA_LANE					(0X3)
1428c2ecf20Sopenharmony_ci#define DSI_FOUR_DATA_LANE					(0x4)
1438c2ecf20Sopenharmony_ci#define DSI_DPI_VIRT_CHANNEL_OFFSET			(0x3)
1448c2ecf20Sopenharmony_ci#define DSI_DBI_VIRT_CHANNEL_OFFSET			(0x5)
1458c2ecf20Sopenharmony_ci#define DSI_DPI_COLOR_FORMAT_RGB565			(0x01 << 7)
1468c2ecf20Sopenharmony_ci#define DSI_DPI_COLOR_FORMAT_RGB666			(0x02 << 7)
1478c2ecf20Sopenharmony_ci#define DSI_DPI_COLOR_FORMAT_RGB666_UNPACK		(0x03 << 7)
1488c2ecf20Sopenharmony_ci#define DSI_DPI_COLOR_FORMAT_RGB888			(0x04 << 7)
1498c2ecf20Sopenharmony_ci#define DSI_DBI_COLOR_FORMAT_OPTION2			(0x05 << 13)
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci#define DSI_INTR_STATE_RXSOTERROR			BIT(0)
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci#define DSI_INTR_STATE_SPL_PKG_SENT			BIT(30)
1548c2ecf20Sopenharmony_ci#define DSI_INTR_STATE_TE				BIT(31)
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci#define DSI_HS_TX_TIMEOUT_MASK				(0xffffff)
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci#define DSI_LP_RX_TIMEOUT_MASK				(0xffffff)
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci#define DSI_TURN_AROUND_TIMEOUT_MASK		(0x3f)
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci#define DSI_RESET_TIMER_MASK				(0xffff)
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci#define DSI_DBI_FIFO_WM_HALF				(0x0)
1658c2ecf20Sopenharmony_ci#define DSI_DBI_FIFO_WM_QUARTER				(0x1)
1668c2ecf20Sopenharmony_ci#define DSI_DBI_FIFO_WM_LOW					(0x2)
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci#define DSI_DPI_TIMING_MASK					(0xffff)
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci#define DSI_INIT_TIMER_MASK					(0xffff)
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci#define DSI_DBI_RETURN_PACK_SIZE_MASK		(0x3ff)
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci#define DSI_LP_BYTECLK_MASK					(0x0ffff)
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_GEN_SHORT_W0			(0x03)
1778c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_GEN_SHORT_W1			(0x13)
1788c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_GEN_SHORT_W2			(0x23)
1798c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_GEN_R0					(0x04)
1808c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_GEN_R1					(0x14)
1818c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_GEN_R2					(0x24)
1828c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_GEN_LONG_W				(0x29)
1838c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_MCS_SHORT_W0			(0x05)
1848c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_MCS_SHORT_W1			(0x15)
1858c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_MCS_R0					(0x06)
1868c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_MCS_LONG_W				(0x39)
1878c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_VC_OFFSET				(0x06)
1888c2ecf20Sopenharmony_ci#define DSI_HS_CTRL_WC_OFFSET				(0x08)
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci#define	DSI_FIFO_GEN_HS_DATA_FULL			BIT(0)
1918c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_HS_DATA_HALF_EMPTY		BIT(1)
1928c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_HS_DATA_EMPTY			BIT(2)
1938c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_LP_DATA_FULL			BIT(8)
1948c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_LP_DATA_HALF_EMPTY		BIT(9)
1958c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_LP_DATA_EMPTY			BIT(10)
1968c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_HS_CTRL_FULL			BIT(16)
1978c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_HS_CTRL_HALF_EMPTY		BIT(17)
1988c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_HS_CTRL_EMPTY			BIT(18)
1998c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_LP_CTRL_FULL			BIT(24)
2008c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_LP_CTRL_HALF_EMPTY		BIT(25)
2018c2ecf20Sopenharmony_ci#define DSI_FIFO_GEN_LP_CTRL_EMPTY			BIT(26)
2028c2ecf20Sopenharmony_ci#define DSI_FIFO_DBI_EMPTY					BIT(27)
2038c2ecf20Sopenharmony_ci#define DSI_FIFO_DPI_EMPTY					BIT(28)
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci#define DSI_DBI_HS_LP_SWITCH_MASK			(0x1)
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci#define DSI_HS_LP_SWITCH_COUNTER_OFFSET		(0x0)
2088c2ecf20Sopenharmony_ci#define DSI_LP_HS_SWITCH_COUNTER_OFFSET		(0x16)
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci#define DSI_DPI_CTRL_HS_SHUTDOWN			(0x00000001)
2118c2ecf20Sopenharmony_ci#define DSI_DPI_CTRL_HS_TURN_ON				(0x00000002)
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci/*dsi power modes*/
2148c2ecf20Sopenharmony_ci#define DSI_POWER_MODE_DISPLAY_ON	BIT(2)
2158c2ecf20Sopenharmony_ci#define DSI_POWER_MODE_NORMAL_ON	BIT(3)
2168c2ecf20Sopenharmony_ci#define DSI_POWER_MODE_SLEEP_OUT	BIT(4)
2178c2ecf20Sopenharmony_ci#define DSI_POWER_MODE_PARTIAL_ON	BIT(5)
2188c2ecf20Sopenharmony_ci#define DSI_POWER_MODE_IDLE_ON		BIT(6)
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_cienum {
2218c2ecf20Sopenharmony_ci	MDFLD_DSI_VIDEO_NON_BURST_MODE_SYNC_PULSE = 1,
2228c2ecf20Sopenharmony_ci	MDFLD_DSI_VIDEO_NON_BURST_MODE_SYNC_EVENTS = 2,
2238c2ecf20Sopenharmony_ci	MDFLD_DSI_VIDEO_BURST_MODE = 3,
2248c2ecf20Sopenharmony_ci};
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci#define DSI_DPI_COMPLETE_LAST_LINE			BIT(2)
2278c2ecf20Sopenharmony_ci#define DSI_DPI_DISABLE_BTA					BIT(3)
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_cistruct mdfld_dsi_connector {
2308c2ecf20Sopenharmony_ci	struct gma_connector base;
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci	int pipe;
2338c2ecf20Sopenharmony_ci	void *private;
2348c2ecf20Sopenharmony_ci	void *pkg_sender;
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	/* Connection status */
2378c2ecf20Sopenharmony_ci	enum drm_connector_status status;
2388c2ecf20Sopenharmony_ci};
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_cistruct mdfld_dsi_encoder {
2418c2ecf20Sopenharmony_ci	struct gma_encoder base;
2428c2ecf20Sopenharmony_ci	void *private;
2438c2ecf20Sopenharmony_ci};
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci/*
2468c2ecf20Sopenharmony_ci * DSI config, consists of one DSI connector, two DSI encoders.
2478c2ecf20Sopenharmony_ci * DRM will pick up on DSI encoder basing on differents configs.
2488c2ecf20Sopenharmony_ci */
2498c2ecf20Sopenharmony_cistruct mdfld_dsi_config {
2508c2ecf20Sopenharmony_ci	struct drm_device *dev;
2518c2ecf20Sopenharmony_ci	struct drm_display_mode *fixed_mode;
2528c2ecf20Sopenharmony_ci	struct drm_display_mode *mode;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci	struct mdfld_dsi_connector *connector;
2558c2ecf20Sopenharmony_ci	struct mdfld_dsi_encoder *encoder;
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci	int changed;
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	int bpp;
2608c2ecf20Sopenharmony_ci	int lane_count;
2618c2ecf20Sopenharmony_ci	/*Virtual channel number for this encoder*/
2628c2ecf20Sopenharmony_ci	int channel_num;
2638c2ecf20Sopenharmony_ci	/*video mode configure*/
2648c2ecf20Sopenharmony_ci	int video_mode;
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	int dvr_ic_inited;
2678c2ecf20Sopenharmony_ci};
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_cistatic inline struct mdfld_dsi_connector *mdfld_dsi_connector(
2708c2ecf20Sopenharmony_ci		struct drm_connector *connector)
2718c2ecf20Sopenharmony_ci{
2728c2ecf20Sopenharmony_ci	struct gma_connector *gma_connector;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	gma_connector = to_gma_connector(connector);
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci	return container_of(gma_connector, struct mdfld_dsi_connector, base);
2778c2ecf20Sopenharmony_ci}
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_cistatic inline struct mdfld_dsi_encoder *mdfld_dsi_encoder(
2808c2ecf20Sopenharmony_ci		struct drm_encoder *encoder)
2818c2ecf20Sopenharmony_ci{
2828c2ecf20Sopenharmony_ci	struct gma_encoder *gma_encoder;
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	gma_encoder = to_gma_encoder(encoder);
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ci	return container_of(gma_encoder, struct mdfld_dsi_encoder, base);
2878c2ecf20Sopenharmony_ci}
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_cistatic inline struct mdfld_dsi_config *
2908c2ecf20Sopenharmony_ci	mdfld_dsi_get_config(struct mdfld_dsi_connector *connector)
2918c2ecf20Sopenharmony_ci{
2928c2ecf20Sopenharmony_ci	if (!connector)
2938c2ecf20Sopenharmony_ci		return NULL;
2948c2ecf20Sopenharmony_ci	return (struct mdfld_dsi_config *)connector->private;
2958c2ecf20Sopenharmony_ci}
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_cistatic inline void *mdfld_dsi_get_pkg_sender(struct mdfld_dsi_config *config)
2988c2ecf20Sopenharmony_ci{
2998c2ecf20Sopenharmony_ci	struct mdfld_dsi_connector *dsi_connector;
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci	if (!config)
3028c2ecf20Sopenharmony_ci		return NULL;
3038c2ecf20Sopenharmony_ci
3048c2ecf20Sopenharmony_ci	dsi_connector = config->connector;
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	if (!dsi_connector)
3078c2ecf20Sopenharmony_ci		return NULL;
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	return dsi_connector->pkg_sender;
3108c2ecf20Sopenharmony_ci}
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_cistatic inline struct mdfld_dsi_config *
3138c2ecf20Sopenharmony_ci	mdfld_dsi_encoder_get_config(struct mdfld_dsi_encoder *encoder)
3148c2ecf20Sopenharmony_ci{
3158c2ecf20Sopenharmony_ci	if (!encoder)
3168c2ecf20Sopenharmony_ci		return NULL;
3178c2ecf20Sopenharmony_ci	return (struct mdfld_dsi_config *)encoder->private;
3188c2ecf20Sopenharmony_ci}
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_cistatic inline struct mdfld_dsi_connector *
3218c2ecf20Sopenharmony_ci	mdfld_dsi_encoder_get_connector(struct mdfld_dsi_encoder *encoder)
3228c2ecf20Sopenharmony_ci{
3238c2ecf20Sopenharmony_ci	struct mdfld_dsi_config *config;
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci	if (!encoder)
3268c2ecf20Sopenharmony_ci		return NULL;
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	config = mdfld_dsi_encoder_get_config(encoder);
3298c2ecf20Sopenharmony_ci	if (!config)
3308c2ecf20Sopenharmony_ci		return NULL;
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_ci	return config->connector;
3338c2ecf20Sopenharmony_ci}
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_cistatic inline void *mdfld_dsi_encoder_get_pkg_sender(
3368c2ecf20Sopenharmony_ci				struct mdfld_dsi_encoder *encoder)
3378c2ecf20Sopenharmony_ci{
3388c2ecf20Sopenharmony_ci	struct mdfld_dsi_config *dsi_config;
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci	dsi_config = mdfld_dsi_encoder_get_config(encoder);
3418c2ecf20Sopenharmony_ci	if (!dsi_config)
3428c2ecf20Sopenharmony_ci		return NULL;
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci	return mdfld_dsi_get_pkg_sender(dsi_config);
3458c2ecf20Sopenharmony_ci}
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_cistatic inline int mdfld_dsi_encoder_get_pipe(struct mdfld_dsi_encoder *encoder)
3488c2ecf20Sopenharmony_ci{
3498c2ecf20Sopenharmony_ci	struct mdfld_dsi_connector *connector;
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	if (!encoder)
3528c2ecf20Sopenharmony_ci		return -1;
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci	connector = mdfld_dsi_encoder_get_connector(encoder);
3558c2ecf20Sopenharmony_ci	if (!connector)
3568c2ecf20Sopenharmony_ci		return -1;
3578c2ecf20Sopenharmony_ci	return connector->pipe;
3588c2ecf20Sopenharmony_ci}
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci/* Export functions */
3618c2ecf20Sopenharmony_ciextern void mdfld_dsi_gen_fifo_ready(struct drm_device *dev,
3628c2ecf20Sopenharmony_ci					u32 gen_fifo_stat_reg, u32 fifo_stat);
3638c2ecf20Sopenharmony_ciextern void mdfld_dsi_brightness_init(struct mdfld_dsi_config *dsi_config,
3648c2ecf20Sopenharmony_ci					int pipe);
3658c2ecf20Sopenharmony_ciextern void mdfld_dsi_brightness_control(struct drm_device *dev, int pipe,
3668c2ecf20Sopenharmony_ci					int level);
3678c2ecf20Sopenharmony_ciextern void mdfld_dsi_output_init(struct drm_device *dev,
3688c2ecf20Sopenharmony_ci					int pipe,
3698c2ecf20Sopenharmony_ci					const struct panel_funcs *p_vid_funcs);
3708c2ecf20Sopenharmony_ciextern void mdfld_dsi_controller_init(struct mdfld_dsi_config *dsi_config,
3718c2ecf20Sopenharmony_ci					int pipe);
3728c2ecf20Sopenharmony_ci
3738c2ecf20Sopenharmony_ciextern int mdfld_dsi_get_power_mode(struct mdfld_dsi_config *dsi_config,
3748c2ecf20Sopenharmony_ci					u32 *mode, bool hs);
3758c2ecf20Sopenharmony_ciextern int mdfld_dsi_panel_reset(struct drm_device *dev, int pipe);
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci#endif /*__MDFLD_DSI_OUTPUT_H__*/
378