/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of The Linux Foundation nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#include <debug.h>
#include <err.h>
#include <smem.h>
#include <msm_panel.h>
#include <board.h>
#include <mipi_dsi.h>

#include "include/panel.h"
#include "panel_display.h"

/*---------------------------------------------------------------------------*/
/* GCDB Panel Database                                                       */
/*---------------------------------------------------------------------------*/
#include "include/panel_toshiba_720p_video.h"
#include "include/panel_nt35590_720p_video.h"
#include "include/panel_nt35590_720p_cmd.h"
#include "include/panel_hx8394a_720p_video.h"
#include "include/panel_nt35596_1080p_video.h"
#include "include/panel_nt35521_720p_video.h"
#include "include/panel_ssd2080m_720p_video.h"
#include "include/panel_jdi_1080p_video.h"

#define DISPLAY_MAX_PANEL_DETECTION 2

#define SSD2080M_720P_VIDEO_PANEL_ON_DELAY 200

/*---------------------------------------------------------------------------*/
/* static panel selection variable                                           */
/*---------------------------------------------------------------------------*/
enum {
TOSHIBA_720P_VIDEO_PANEL,
NT35590_720P_CMD_PANEL,
NT35590_720P_VIDEO_PANEL,
NT35596_1080P_VIDEO_PANEL,
HX8394A_720P_VIDEO_PANEL,
NT35521_720P_VIDEO_PANEL,
SSD2080M_720P_VIDEO_PANEL,
JDI_1080P_VIDEO_PANEL,
UNKNOWN_PANEL
};

enum target_subtype {
	HW_PLATFORM_SUBTYPE_720P = 0,
	HW_PLATFORM_SUBTYPE_SKUAA = 1,
	HW_PLATFORM_SUBTYPE_SKUF = 2,
	HW_PLATFORM_SUBTYPE_1080P = 2,
	HW_PLATFORM_SUBTYPE_SKUAB = 3,
	HW_PLATFORM_SUBTYPE_SKUG = 5,
};

static uint32_t panel_id;

int oem_panel_rotation()
{
	int ret = NO_ERROR;
	switch (panel_id) {
	case TOSHIBA_720P_VIDEO_PANEL:
		ret = mipi_dsi_cmds_tx(toshiba_720p_video_rotation,
				TOSHIBA_720P_VIDEO_ROTATION);
		break;
	case NT35590_720P_CMD_PANEL:
		ret = mipi_dsi_cmds_tx(nt35590_720p_cmd_rotation,
				NT35590_720P_CMD_ROTATION);
		break;
	case NT35590_720P_VIDEO_PANEL:
		ret = mipi_dsi_cmds_tx(nt35590_720p_video_rotation,
				NT35590_720P_VIDEO_ROTATION);
		break;
	}

	return ret;
}

int oem_panel_on()
{
	/* OEM can keep there panel spefic on instructions in this
	function */
	if (panel_id == SSD2080M_720P_VIDEO_PANEL) {
		/* SSD2080M needs extra delay to avoid unexpected artifacts */
		mdelay(SSD2080M_720P_VIDEO_PANEL_ON_DELAY);
	}
	return NO_ERROR;
}

int oem_panel_off()
{
	/* OEM can keep there panel spefic off instructions in this
	function */
	return NO_ERROR;
}

static void init_panel_data(struct panel_struct *panelstruct,
			struct msm_panel_info *pinfo,
			struct mdss_dsi_phy_ctrl *phy_db)
{
	switch (panel_id) {
	case TOSHIBA_720P_VIDEO_PANEL:
		panelstruct->paneldata    = &toshiba_720p_video_panel_data;
		panelstruct->panelres     = &toshiba_720p_video_panel_res;
		panelstruct->color        = &toshiba_720p_video_color;
		panelstruct->videopanel   = &toshiba_720p_video_video_panel;
		panelstruct->commandpanel = &toshiba_720p_video_command_panel;
		panelstruct->state        = &toshiba_720p_video_state;
		panelstruct->laneconfig   = &toshiba_720p_video_lane_config;
		panelstruct->paneltiminginfo
					 = &toshiba_720p_video_timing_info;
		panelstruct->panelresetseq
					 = &toshiba_720p_video_panel_reset_seq;
		panelstruct->backlightinfo = &toshiba_720p_video_backlight;
		pinfo->mipi.panel_cmds
					= toshiba_720p_video_on_command;
		pinfo->mipi.num_of_panel_cmds
					= TOSHIBA_720P_VIDEO_ON_COMMAND;
		memcpy(phy_db->timing,
			toshiba_720p_video_timings, TIMING_SIZE);
		break;
	case NT35590_720P_VIDEO_PANEL:
		panelstruct->paneldata    = &nt35590_720p_video_panel_data;
		panelstruct->panelres     = &nt35590_720p_video_panel_res;
		panelstruct->color        = &nt35590_720p_video_color;
		panelstruct->videopanel   = &nt35590_720p_video_video_panel;
		panelstruct->commandpanel = &nt35590_720p_video_command_panel;
		panelstruct->state        = &nt35590_720p_video_state;
		panelstruct->laneconfig   = &nt35590_720p_video_lane_config;
		panelstruct->paneltiminginfo
					 = &nt35590_720p_video_timing_info;
		panelstruct->panelresetseq
					 = &nt35590_720p_video_panel_reset_seq;
		panelstruct->backlightinfo = &nt35590_720p_video_backlight;
		pinfo->mipi.panel_cmds
					= nt35590_720p_video_on_command;
		pinfo->mipi.num_of_panel_cmds
					= NT35590_720P_VIDEO_ON_COMMAND;
		memcpy(phy_db->timing,
				nt35590_720p_video_timings, TIMING_SIZE);
		break;
	case NT35521_720P_VIDEO_PANEL:
		panelstruct->paneldata    = &nt35521_720p_video_panel_data;
		panelstruct->panelres     = &nt35521_720p_video_panel_res;
		panelstruct->color        = &nt35521_720p_video_color;
		panelstruct->videopanel   = &nt35521_720p_video_video_panel;
		panelstruct->commandpanel = &nt35521_720p_video_command_panel;
		panelstruct->state        = &nt35521_720p_video_state;
		panelstruct->laneconfig   = &nt35521_720p_video_lane_config;
		panelstruct->paneltiminginfo
					 = &nt35521_720p_video_timing_info;
		panelstruct->panelresetseq
					 = &nt35521_720p_video_panel_reset_seq;
		panelstruct->backlightinfo = &nt35521_720p_video_backlight;
		pinfo->mipi.panel_cmds
					= nt35521_720p_video_on_command;
		pinfo->mipi.num_of_panel_cmds
					= NT35521_720P_VIDEO_ON_COMMAND;
		memcpy(phy_db->timing,
				nt35521_720p_video_timings, TIMING_SIZE);
		break;
	case SSD2080M_720P_VIDEO_PANEL:
		panelstruct->paneldata    = &ssd2080m_720p_video_panel_data;
		panelstruct->panelres     = &ssd2080m_720p_video_panel_res;
		panelstruct->color        = &ssd2080m_720p_video_color;
		panelstruct->videopanel   = &ssd2080m_720p_video_video_panel;
		panelstruct->commandpanel = &ssd2080m_720p_video_command_panel;
		panelstruct->state        = &ssd2080m_720p_video_state;
		panelstruct->laneconfig   = &ssd2080m_720p_video_lane_config;
		panelstruct->paneltiminginfo
					 = &ssd2080m_720p_video_timing_info;
		panelstruct->panelresetseq
					 = &ssd2080m_720p_video_panel_reset_seq;
		panelstruct->backlightinfo = &ssd2080m_720p_video_backlight;
		pinfo->mipi.panel_cmds
					= ssd2080m_720p_video_on_command;
		pinfo->mipi.num_of_panel_cmds
					= SSD2080M_720P_VIDEO_ON_COMMAND;
		memcpy(phy_db->timing,
				ssd2080m_720p_video_timings, TIMING_SIZE);
		break;
	case HX8394A_720P_VIDEO_PANEL:
		panelstruct->paneldata    = &hx8394a_720p_video_panel_data;
		panelstruct->panelres     = &hx8394a_720p_video_panel_res;
		panelstruct->color        = &hx8394a_720p_video_color;
		panelstruct->videopanel   = &hx8394a_720p_video_video_panel;
		panelstruct->commandpanel = &hx8394a_720p_video_command_panel;
		panelstruct->state        = &hx8394a_720p_video_state;
		panelstruct->laneconfig   = &hx8394a_720p_video_lane_config;
		panelstruct->paneltiminginfo
					 = &hx8394a_720p_video_timing_info;
		panelstruct->panelresetseq
					 = &hx8394a_720p_video_panel_reset_seq;
		panelstruct->backlightinfo = &hx8394a_720p_video_backlight;
		pinfo->mipi.panel_cmds
					= hx8394a_720p_video_on_command;
		pinfo->mipi.num_of_panel_cmds
					= HX8394A_720P_VIDEO_ON_COMMAND;
		memcpy(phy_db->timing,
				hx8394a_720p_video_timings, TIMING_SIZE);
		pinfo->mipi.signature = HX8394A_720P_VIDEO_SIGNATURE;
		break;

	case NT35590_720P_CMD_PANEL:
		panelstruct->paneldata    = &nt35590_720p_cmd_panel_data;
		panelstruct->panelres     = &nt35590_720p_cmd_panel_res;
		panelstruct->color        = &nt35590_720p_cmd_color;
		panelstruct->videopanel   = &nt35590_720p_cmd_video_panel;
		panelstruct->commandpanel = &nt35590_720p_cmd_command_panel;
		panelstruct->state        = &nt35590_720p_cmd_state;
		panelstruct->laneconfig   = &nt35590_720p_cmd_lane_config;
		panelstruct->paneltiminginfo = &nt35590_720p_cmd_timing_info;
		panelstruct->panelresetseq
					= &nt35590_720p_cmd_panel_reset_seq;
		panelstruct->backlightinfo = &nt35590_720p_cmd_backlight;
		pinfo->mipi.panel_cmds
					= nt35590_720p_cmd_on_command;
		pinfo->mipi.num_of_panel_cmds
					= NT35590_720P_CMD_ON_COMMAND;
		memcpy(phy_db->timing,
				nt35590_720p_cmd_timings, TIMING_SIZE);
		break;
	case NT35596_1080P_VIDEO_PANEL:
		panelstruct->paneldata    = &nt35596_1080p_video_panel_data;
		panelstruct->panelres     = &nt35596_1080p_video_panel_res;
		panelstruct->color        = &nt35596_1080p_video_color;
		panelstruct->videopanel   = &nt35596_1080p_video_video_panel;
		panelstruct->commandpanel = &nt35596_1080p_video_command_panel;
		panelstruct->state        = &nt35596_1080p_video_state;
		panelstruct->laneconfig   = &nt35596_1080p_video_lane_config;
		panelstruct->paneltiminginfo
					= &nt35596_1080p_video_timing_info;
		panelstruct->panelresetseq
					= &nt35596_1080p_video_panel_reset_seq;
		panelstruct->backlightinfo
					= &nt35596_1080p_video_backlight;
		pinfo->mipi.panel_cmds
					= nt35596_1080p_video_on_command;
		pinfo->mipi.num_of_panel_cmds
					= NT35596_1080P_VIDEO_ON_COMMAND;
		memcpy(phy_db->timing,
				nt35596_1080p_video_timings, TIMING_SIZE);
		pinfo->mipi.signature = NT35596_1080P_VIDEO_SIGNATURE;
		break;
	case JDI_1080P_VIDEO_PANEL:
		panelstruct->paneldata    = &jdi_1080p_video_panel_data;
		panelstruct->paneldata->panel_with_enable_gpio = 1;
		panelstruct->panelres     = &jdi_1080p_video_panel_res;
		panelstruct->color        = &jdi_1080p_video_color;
		panelstruct->videopanel   = &jdi_1080p_video_video_panel;
		panelstruct->commandpanel = &jdi_1080p_video_command_panel;
		panelstruct->state        = &jdi_1080p_video_state;
		panelstruct->laneconfig   = &jdi_1080p_video_lane_config;
		panelstruct->paneltiminginfo
			= &jdi_1080p_video_timing_info;
		panelstruct->panelresetseq
					 = &jdi_1080p_video_panel_reset_seq;
		panelstruct->backlightinfo = &jdi_1080p_video_backlight;
		pinfo->mipi.panel_cmds
			= jdi_1080p_video_on_command;
		pinfo->mipi.num_of_panel_cmds
			= JDI_1080P_VIDEO_ON_COMMAND;
		memcpy(phy_db->timing,
			jdi_1080p_video_timings, TIMING_SIZE);
		break;
        case UNKNOWN_PANEL:
                memset(panelstruct, 0, sizeof(struct panel_struct));
                memset(pinfo->mipi.panel_cmds, 0, sizeof(struct mipi_dsi_cmd));
                pinfo->mipi.num_of_panel_cmds = 0;
                memset(phy_db->timing, 0, TIMING_SIZE);
                pinfo->mipi.signature = 0;
                break;
	}
}

uint32_t oem_panel_max_auto_detect_panels()
{
        return target_panel_auto_detect_enabled() ?
                        DISPLAY_MAX_PANEL_DETECTION : 0;
}

static uint32_t auto_pan_loop = 0;

bool oem_panel_select(struct panel_struct *panelstruct,
			struct msm_panel_info *pinfo,
			struct mdss_dsi_phy_ctrl *phy_db)
{
	uint32_t hw_id = board_hardware_id();
	uint32_t target_id = board_target_id();
	uint32_t nt35590_panel_id = NT35590_720P_VIDEO_PANEL;
	uint32_t hw_subtype = board_hardware_subtype();
	bool ret = true;

#if DISPLAY_TYPE_CMD_MODE
	nt35590_panel_id = NT35590_720P_CMD_PANEL;
#endif

	switch (hw_id) {
	case HW_PLATFORM_QRD:
		if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUF) {
			panel_id = NT35521_720P_VIDEO_PANEL;
		} else if (hw_subtype == HW_PLATFORM_SUBTYPE_SKUG) {
			panel_id = SSD2080M_720P_VIDEO_PANEL;
		} else {
			if (((target_id >> 16) & 0xFF) == 0x1 || ((target_id >> 16) & 0xFF) == 0x3) //EVT || PVT
				panel_id = nt35590_panel_id;
			else if (((target_id >> 16) & 0xFF) == 0x2) { //DVT
				panel_id = HX8394A_720P_VIDEO_PANEL;
				switch (auto_pan_loop) {
					case 0:
						panel_id = HX8394A_720P_VIDEO_PANEL;
						break;
					case 1:
						panel_id = NT35596_1080P_VIDEO_PANEL;
						break;
					default:
						panel_id = UNKNOWN_PANEL;
						ret = false;
						dprintf(CRITICAL, "Unknown panel\n");
						return ret;
				}
				auto_pan_loop++;
			}
			else {
				dprintf(CRITICAL, "Not supported device, target_id=%x\n"
									, target_id);
				return false;
			}
		}
		break;
	case HW_PLATFORM_MTP:
	case HW_PLATFORM_SURF:
		if (hw_subtype == HW_PLATFORM_SUBTYPE_720P) {
			panel_id = nt35590_panel_id;
		} else if (hw_subtype == HW_PLATFORM_SUBTYPE_1080P) {
			panel_id = JDI_1080P_VIDEO_PANEL;
		} else {
			dprintf(CRITICAL, "Unsupported target_id=%d hw_subtype=%d\n"
				, target_id, hw_subtype);
			return false;
		}
		break;
	default:
		dprintf(CRITICAL, "Display not enabled for %d HW type\n"
								, hw_id);
		return false;
	}

	init_panel_data(panelstruct, pinfo, phy_db);

	return ret;
}
