<commit_before>/* 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 "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * 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.
 *
 */

/*---------------------------------------------------------------------------*/
/* HEADER files                                                              */
/*---------------------------------------------------------------------------*/
#include <stdint.h>
#include <msm_panel.h>
#include <mipi_dsi.h>
#include <sys/types.h>
#include <platform/iomap.h>
#include <err.h>
#include <reg.h>
#include <mdp5.h>


/*---------------------------------------------------------------------------*/
/* Panel Header                                                              */
/*---------------------------------------------------------------------------*/
#include "panel_display.h"
#include "include/panel.h"

/*---------------------------------------------------------------------------*/
/* Panel Init                                                                */
/*---------------------------------------------------------------------------*/
int dsi_panel_init(struct msm_panel_info *pinfo,
			struct panel_struct *pstruct)
{
	/* Resolution setting*/
	pinfo->xres = pstruct->panelres->panel_width;
	pinfo->yres = pstruct->panelres->panel_height;
	pinfo->lcdc.h_back_porch = pstruct->panelres->hback_porch;
	pinfo->lcdc.h_front_porch = pstruct->panelres->hfront_porch;
	pinfo->lcdc.h_pulse_width = pstruct->panelres->hpulse_width;
	pinfo->lcdc.v_back_porch = pstruct->panelres->vback_porch;
	pinfo->lcdc.v_front_porch = pstruct->panelres->vfront_porch;
	pinfo->lcdc.v_pulse_width = pstruct->panelres->vpulse_width;
	pinfo->lcdc.hsync_skew = pstruct->panelres->hsync_skew;
	pinfo->lcdc.xres_pad = pstruct->panelres->hleft_border +
				pstruct->panelres->hright_border;
	pinfo->lcdc.yres_pad = pstruct->panelres->vtop_border +
				 pstruct->panelres->vbottom_border;

	if (pstruct->paneldata->panel_operating_mode & DUAL_PIPE_FLAG)
		pinfo->lcdc.dual_pipe = 1;
	if (pstruct->paneldata->panel_operating_mode & PIPE_SWAP_FLAG)
		pinfo->lcdc.pipe_swap = 1;
	if (pstruct->paneldata->panel_operating_mode & SPLIT_DISPLAY_FLAG)
		pinfo->lcdc.split_display = 1;

	/* Color setting*/
	pinfo->lcdc.border_clr = pstruct->color->border_color;
	pinfo->lcdc.underflow_clr = pstruct->color->underflow_color;
	pinfo->mipi.rgb_swap = pstruct->color->color_order;
	switch (pinfo->bpp) {
	case BPP_16:
		pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
		break;
	case BPP_18:
		if (pstruct->color->pixel_packing)
			pinfo->mipi.dst_format
				= DSI_VIDEO_DST_FORMAT_RGB666_LOOSE;
		else
			pinfo->mipi.dst_format
				 = DSI_VIDEO_DST_FORMAT_RGB666;
		break;
	case BPP_24:
	default:
		pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
		break;
	}

	/* Panel generic info */
	pinfo->mipi.mode = pstruct->paneldata->panel_type;
	if (pinfo->mipi.mode) {
		pinfo->type = MIPI_CMD_PANEL;
	} else {
		pinfo->type = MIPI_VIDEO_PANEL;
	}
	pinfo->bpp = pstruct->color->color_format;
	pinfo->clk_rate = pstruct->paneldata->panel_clockrate;
	pinfo->rotation = pstruct->paneldata->panel_orientation;
	pinfo->mipi.interleave_mode = pstruct->paneldata->interleave_mode;
	pinfo->mipi.broadcast = pstruct->paneldata->panel_broadcast_mode;
	pinfo->lowpowerstop = pstruct->paneldata->dsi_lp11_atinit;
	pinfo->mipi.vc = pstruct->paneldata->dsi_virtualchannel_id;
	pinfo->mipi.frame_rate = pstruct->paneldata->panel_framerate;
	pinfo->mipi.stream = pstruct->paneldata->dsi_stream;
	if (pstruct->paneldata->panel_operating_mode & DUAL_DSI_FLAG)
		pinfo->mipi.dual_dsi = 1;
	pinfo->mipi.mode_gpio_state = pstruct->paneldata->mode_gpio_state;
	pinfo->mipi.bitclock = pstruct->paneldata->panel_bitclock_freq;

	/* Video Panel configuration */
	pinfo->mipi.pulse_mode_hsa_he = pstruct->videopanel->hsync_pulse;
	pinfo->mipi.hfp_power_stop = pstruct->videopanel->hfp_power_mode;
	pinfo->mipi.hbp_power_stop = pstruct->videopanel->hbp_power_mode;
	pinfo->mipi.hsa_power_stop = pstruct->videopanel->hsa_power_mode;
	pinfo->mipi.eof_bllp_power_stop
			 = pstruct->videopanel->bllp_eof_power_mode;
	pinfo->mipi.bllp_power_stop = pstruct->videopanel->bllp_power_mode;
	pinfo->mipi.traffic_mode = pstruct->videopanel->traffic_mode;
	pinfo->mipi.eof_bllp_power = pstruct->videopanel->bllp_eof_power;

	/* Command Panel configuratoin */
	pinfo->mipi.insert_dcs_cmd = pstruct->commandpanel->tedcs_command;
	pinfo->mipi.wr_mem_continue
			 = pstruct->commandpanel->tevsync_continue_lines;
	pinfo->mipi.wr_mem_start
			 = pstruct->commandpanel->tevsync_rdptr_irqline;
	pinfo->mipi.te_sel = pstruct->commandpanel->tepin_select;

	/* Data lane configuraiton */
	pinfo->mipi.num_of_lanes = pstruct->laneconfig->dsi_lanes;
	pinfo->mipi.data_lane0 = pstruct->laneconfig->lane0_state;<commit_msg>dev: gcdb: Initialize the flag to indicate use of panel enable gpio<commit_after>/* 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 "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * 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.
 *
 */

/*---------------------------------------------------------------------------*/
/* HEADER files                                                              */
/*---------------------------------------------------------------------------*/
#include <stdint.h>
#include <msm_panel.h>
#include <mipi_dsi.h>
#include <sys/types.h>
#include <platform/iomap.h>
#include <err.h>
#include <reg.h>
#include <mdp5.h>


/*---------------------------------------------------------------------------*/
/* Panel Header                                                              */
/*---------------------------------------------------------------------------*/
#include "panel_display.h"
#include "include/panel.h"

/*---------------------------------------------------------------------------*/
/* Panel Init                                                                */
/*---------------------------------------------------------------------------*/
int dsi_panel_init(struct msm_panel_info *pinfo,
			struct panel_struct *pstruct)
{
	/* Resolution setting*/
	pinfo->xres = pstruct->panelres->panel_width;
	pinfo->yres = pstruct->panelres->panel_height;
	pinfo->lcdc.h_back_porch = pstruct->panelres->hback_porch;
	pinfo->lcdc.h_front_porch = pstruct->panelres->hfront_porch;
	pinfo->lcdc.h_pulse_width = pstruct->panelres->hpulse_width;
	pinfo->lcdc.v_back_porch = pstruct->panelres->vback_porch;
	pinfo->lcdc.v_front_porch = pstruct->panelres->vfront_porch;
	pinfo->lcdc.v_pulse_width = pstruct->panelres->vpulse_width;
	pinfo->lcdc.hsync_skew = pstruct->panelres->hsync_skew;
	pinfo->lcdc.xres_pad = pstruct->panelres->hleft_border +
				pstruct->panelres->hright_border;
	pinfo->lcdc.yres_pad = pstruct->panelres->vtop_border +
				 pstruct->panelres->vbottom_border;

	if (pstruct->paneldata->panel_operating_mode & DUAL_PIPE_FLAG)
		pinfo->lcdc.dual_pipe = 1;
	if (pstruct->paneldata->panel_operating_mode & PIPE_SWAP_FLAG)
		pinfo->lcdc.pipe_swap = 1;
	if (pstruct->paneldata->panel_operating_mode & SPLIT_DISPLAY_FLAG)
		pinfo->lcdc.split_display = 1;

	/* Color setting*/
	pinfo->lcdc.border_clr = pstruct->color->border_color;
	pinfo->lcdc.underflow_clr = pstruct->color->underflow_color;
	pinfo->mipi.rgb_swap = pstruct->color->color_order;
	switch (pinfo->bpp) {
	case BPP_16:
		pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB565;
		break;
	case BPP_18:
		if (pstruct->color->pixel_packing)
			pinfo->mipi.dst_format
				= DSI_VIDEO_DST_FORMAT_RGB666_LOOSE;
		else
			pinfo->mipi.dst_format
				 = DSI_VIDEO_DST_FORMAT_RGB666;
		break;
	case BPP_24:
	default:
		pinfo->mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888;
		break;
	}

	/* Panel generic info */
	pinfo->mipi.mode = pstruct->paneldata->panel_type;
	if (pinfo->mipi.mode) {
		pinfo->type = MIPI_CMD_PANEL;
	} else {
		pinfo->type = MIPI_VIDEO_PANEL;
	}
	pinfo->bpp = pstruct->color->color_format;
	pinfo->clk_rate = pstruct->paneldata->panel_clockrate;
	pinfo->rotation = pstruct->paneldata->panel_orientation;
	pinfo->mipi.interleave_mode = pstruct->paneldata->interleave_mode;
	pinfo->mipi.broadcast = pstruct->paneldata->panel_broadcast_mode;
	pinfo->lowpowerstop = pstruct->paneldata->dsi_lp11_atinit;
	pinfo->mipi.vc = pstruct->paneldata->dsi_virtualchannel_id;
	pinfo->mipi.frame_rate = pstruct->paneldata->panel_framerate;
	pinfo->mipi.stream = pstruct->paneldata->dsi_stream;
	if (pstruct->paneldata->panel_operating_mode & DUAL_DSI_FLAG)
		pinfo->mipi.dual_dsi = 1;
	pinfo->mipi.mode_gpio_state = pstruct->paneldata->mode_gpio_state;
	pinfo->mipi.bitclock = pstruct->paneldata->panel_bitclock_freq;
	pinfo->mipi.use_enable_gpio =
		pstruct->paneldata->panel_with_enable_gpio;

	/* Video Panel configuration */
	pinfo->mipi.pulse_mode_hsa_he = pstruct->videopanel->hsync_pulse;
	pinfo->mipi.hfp_power_stop = pstruct->videopanel->hfp_power_mode;
	pinfo->mipi.hbp_power_stop = pstruct->videopanel->hbp_power_mode;
	pinfo->mipi.hsa_power_stop = pstruct->videopanel->hsa_power_mode;
	pinfo->mipi.eof_bllp_power_stop
			 = pstruct->videopanel->bllp_eof_power_mode;
	pinfo->mipi.bllp_power_stop = pstruct->videopanel->bllp_power_mode;
	pinfo->mipi.traffic_mode = pstruct->videopanel->traffic_mode;
	pinfo->mipi.eof_bllp_power = pstruct->videopanel->bllp_eof_power;

	/* Command Panel configuratoin */
	pinfo->mipi.insert_dcs_cmd = pstruct->commandpanel->tedcs_command;
	pinfo->mipi.wr_mem_continue
			 = pstruct->commandpanel->tevsync_continue_lines;
	pinfo->mipi.wr_mem_start
			 = pstruct->commandpanel->tevsync_rdptr_irqline;
	pinfo->mipi.te_sel = pstruct->commandpanel->tepin_select;

	/* Data lane configuraiton */
	pinfo->mipi.num_of_lanes = pstruct->laneconfig->dsi_lanes;
	pinfo->mipi.data_lane0 = pstruct->laneconfig->lane0_state;
{'fraction_non_alphanumeric': 0.17578155916106056, 'fraction_numerical': 0.004907004352987732, 'mean_word_length': 2.9193548387096775, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 314, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4310402', 'n_tokens_mistral': 4371, 'n_tokens_neox': 4150, 'n_words': 810}