static
int sdc16x25_8_cmd_power_on(
			    struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int ret;
	u8 cmd;

	PSB_DEBUG_ENTRY("\n");

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	/* display on */
	cmd = set_display_on;
	ret = mdfld_dsi_send_mcs_short_lp(sender,
					  cmd, 0, 0, MDFLD_DSI_SEND_PACKAGE);
	if (ret)
		goto err_out;
	return 0;

err_out:
	DRM_ERROR("failed to send command %#x\n", cmd);
	return ret;
}
Пример #2
0
static
int mdfld_auo_dsi_cmd_set_brightness(struct mdfld_dsi_config *dsi_config,
		int level)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	u8 backlight_value;
	u8 param[4];
	int err = 0;

	PSB_DEBUG_ENTRY("level = %d\n", level);

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	backlight_value = ((level * 0xff) / 100) & 0xff;

	param[0] = backlight_value;
	param[1] = 0x00;
	param[2] = 0x00;
	err = mdfld_dsi_send_dcs(sender,
			write_display_brightness,
			param,
			3,
			CMD_DATA_SRC_SYSTEM_MEM,
			MDFLD_DSI_SEND_PACKAGE);

	if (err)
		DRM_ERROR("DCS 0x%x sent failed\n", exit_sleep_mode);

	return 0;
}
Пример #3
0
int mdfld_dsi_sharp25x16_ic_init(struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_pkg_sender *sender
		= mdfld_dsi_get_pkg_sender(dsi_config);
	struct drm_device *dev = dsi_config->dev;
	int err = 0;
	int i;

	PSB_DEBUG_ENTRY("\n");

	if (!sender) {
		DRM_ERROR("Cannot get sender\n");
		return -EINVAL;
	}

	for (i = 0; i < 7; i++) {
		err = mdfld_dsi_send_gen_long_hs(sender, sharp_mode_set_data[i],
				3,
				MDFLD_DSI_SEND_PACKAGE);
		if (err) {
			DRM_ERROR("%s: %d: Set Mode data\n", __func__, __LINE__);
			goto ic_init_err;
		}
		REG_WRITE(MIPIA_HS_GEN_CTRL_REG, 5);
	}
	return 0;

ic_init_err:
	err = -EIO;
	return err;
}
Пример #4
0
static
int mdfld_dsi_h8c7_cmd_set_brightness(struct mdfld_dsi_config *dsi_config,
		int level)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int duty_val = 0;
	static bool b_cabc_initialized = false;

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	if (drm_psb_enable_cabc && !b_cabc_initialized) {
		h8c7_disable_cabc[1] = 0x2;
		mdfld_dsi_send_mcs_long_hs(sender, h8c7_disable_cabc,
					   sizeof(h8c7_disable_cabc), 0);
		mdelay(5);
		mdfld_dsi_send_gen_long_hs(sender, h8c7_mcs_protect_off, 4, 0);
		mdfld_dsi_send_mcs_long_hs(sender, h8c7_set_cabc_gain, 10, 0);
		mdfld_dsi_send_gen_long_hs(sender, h8c7_mcs_protect_on, 4, 0);
		b_cabc_initialized = true;
	}

	duty_val = (255 * level) / 100;
	h8c7_set_brightness[1] = duty_val;

	mdfld_dsi_send_mcs_short_lp(sender, h8c7_set_brightness[0], h8c7_set_brightness[1], 1, 0);

	return 0;
}
static int otm1284a_vid_power_off(struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int err;

	printk("[DISP] %s\n", __func__);
	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}
	cancel_delayed_work_sync(&orise1284a_panel_reset_delay_work);
	usleep_range(1000, 1500);
	/* Send power off command*/
	err = mdfld_dsi_send_mcs_short_hs(sender, MIPI_DCS_SET_DISPLAY_OFF, 0,
					  0, MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("Failed to Set Display Off\n");
		return err;
	}

	err = mdfld_dsi_send_mcs_short_hs(sender, MIPI_DCS_ENTER_SLEEP_MODE, 0,
					  0, MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("Failed to Enter Sleep Mode\n");
		return err;
	}

	usleep_range(50000, 55000);

	return 0;
}
Пример #6
0
static int
sharp10x19_cmd_set_brightness( struct mdfld_dsi_config *dsi_config, int level)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	u8 duty_val = 0;
	struct drm_device *dev = dsi_config->dev;

	PSB_DEBUG_ENTRY("level = %d\n", level);

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	duty_val = (0xFF * level) / 255;
	mdfld_dsi_send_mcs_short_hs(sender,
			write_display_brightness, duty_val, 1,
			MDFLD_DSI_SEND_PACKAGE);
	if (is_dual_panel(dev)) {
		sender->work_for_slave_panel = true;
		mdfld_dsi_send_mcs_short_hs(sender,
				write_display_brightness, duty_val, 1,
				MDFLD_DSI_SEND_PACKAGE);
		sender->work_for_slave_panel = false;
	}
	return 0;
}
static int otm1901a_vid_drv_ic_init(struct mdfld_dsi_config *dsi_config){

	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int i;

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	printk("[DISP] %s\n", __func__);

	gpio_set_value_cansleep(panel_reset_gpio, 0);
	usleep_range(10000, 10100);
	gpio_set_value_cansleep(panel_reset_gpio, 1);
	usleep_range(10000, 10100);

	/* panel initial settings */
	mdfld_dsi_send_mcs_short_lp(sender, 0x00, 0x00, 1, MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_gen_long_lp(sender, cm_FF_1, sizeof(cm_FF_1), MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_mcs_short_lp(sender, 0x00, 0x80, 1, MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_gen_long_lp(sender, cm_FF_2, sizeof(cm_FF_2), MDFLD_DSI_SEND_PACKAGE);

	for(i = 0; i < otm1901a_power_on_table_size; i++)
		send_mipi_cmd_orise(sender, &otm1901a_power_on_table[i]);

	mdfld_dsi_send_mcs_short_lp(sender, 0x11, 0, 0, MDFLD_DSI_SEND_PACKAGE);
	mdelay(200);
	mdfld_dsi_send_mcs_short_lp(sender, 0x29, 0, 0, MDFLD_DSI_SEND_PACKAGE);

	return 0;
}
static int ls04x_drv_ic_init(struct mdfld_dsi_config *dsi_config)
{
	int r = 0;
	u8 data[16];
	struct mdfld_dsi_pkg_sender *sender
				= mdfld_dsi_get_pkg_sender(dsi_config);

	PSB_DEBUG_ENTRY("\n");

	if (!sender)
		return -EINVAL;
	sender->status = MDFLD_DSI_PKG_SENDER_FREE;
	memset(data, 0, sizeof(data));
	mdfld_dsi_send_gen_short_hs(sender,
			ls04x_mcap[0],
			ls04x_mcap[1], 2,
			MDFLD_DSI_SEND_PACKAGE);

	r = mdfld_dsi_read_gen_hs(sender,
			ls04x_device_code_read[0], 0, 1, data, 5);
	PSB_DEBUG_GENERAL("device code read: %d %02x %02x %02x %02x %02x\n",
			  r, data[0], data[1], data[2], data[3], data[4]);

	if ((data[2] == 0x14) && (data[3] == 0x13))
		r = ls04x_igzo_drv_ic_init(dsi_config);
	else if ((data[2] == 0x34) && (data[3] == 0x15))
		r = ls04x_cgs_drv_ic_init(dsi_config);
	else if ((data[2] == 0x94) && (data[3] == 0x31))
		r = ls04x_igzo_g8_drv_ic_init(dsi_config);
	else
		DRM_INFO("unknown device code: %02x %02x\n", data[2], data[3]);

	return r;
}
static int ls04x_cgs_cmd_set_brightness(struct mdfld_dsi_config *dsi_config,
					int level)
{
	if (drm_psb_enable_cabc) {
		struct mdfld_dsi_pkg_sender *sender
			= mdfld_dsi_get_pkg_sender(dsi_config);
		if (!sender)
			return -EINVAL;

		u8 brightness[3] = {0, };

		brightness[0] = write_display_brightness;
		brightness[1] = 0;
		brightness[2] = (level * 255 / 100) & 0xff;
		mdfld_dsi_send_mcs_long_hs(sender,
				brightness,
				sizeof(brightness),
				MDFLD_DSI_SEND_PACKAGE);
	} else {
		u8 brightness[2];

		PSB_DEBUG_ENTRY("%d\n", level);
		brightness[0] = 0x0a;
		brightness[1] = level * 255 / 100;
		i2c_master_send(i2c_client, brightness, sizeof(brightness));
		brightness[0] = 0x0b;
		i2c_master_send(i2c_client, brightness, sizeof(brightness));
	}

	return 0;
}
static int ls04x_cgs_drv_ic_init(struct mdfld_dsi_config *dsi_config)
{
	DRM_INFO("CGS panel detected!\n");
	pwm_width = 8;
	return handle_dsi_init_commands(mdfld_dsi_get_pkg_sender(dsi_config),
						cgs_init_commands);
}
static int samsungWQHD_cmd_power_off(struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int err;

	printk("[DISP] %s\n", __func__);
	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	usleep_range(1000, 1500);
	/* Send power off command*/
	err = mdfld_dsi_send_mcs_short_hs(sender, 0x28, 0, 0, MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("Failed to Set Display Off\n");
		return err;
	}
	usleep_range(35000, 35500);
	err = mdfld_dsi_send_mcs_short_hs(sender, 0x10, 0, 0, MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("Failed to Enter Sleep Mode\n");
		return err;
	}
	usleep_range(150000, 150500);

	/* Turn off VBAT*/
	gpio_set_value_cansleep(stb1_en_gpio, 0);
	gpio_set_value_cansleep(stb2_en_gpio, 0);
	return 0;
}
static int ls04x_igzo_drv_ic_init(struct mdfld_dsi_config *dsi_config)
{
	DRM_INFO("IGZO panel detected!\n");
	pwm_width = 12;
	return handle_dsi_init_commands(mdfld_dsi_get_pkg_sender(dsi_config),
						igzo_init_commands);
}
Пример #13
0
static int mdfld_dsi_sharp25x16_set_brightness(struct mdfld_dsi_config *dsi_config,
		int level)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	struct drm_device *dev = dsi_config->dev;
	u8 duty_val = 0;

	PSB_DEBUG_ENTRY("level = %d\n", level);

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	duty_val = (0xFF * level) / 255;
	if (duty_val < 12)
		duty_val = 0;
	sharp_set_brightness[2] = duty_val;
	mdfld_dsi_send_gen_long_hs(sender, sharp_set_brightness,
				3,
				MDFLD_DSI_SEND_PACKAGE);

	REG_WRITE(MIPIA_HS_GEN_CTRL_REG, 5);
	return 0;
}
Пример #14
0
static
int jdi25x16_cmd_set_brightness(
		struct mdfld_dsi_config *dsi_config,
		int level)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	u8 duty_val = 0;
	int i;

	PSB_DEBUG_ENTRY("level = %d\n", level);

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	duty_val = (0xFF * level) / 255;
	for (i = 0; i < 2; i++) {
		if (i == 0)
			sender->work_for_slave_panel = false;
		else
			sender->work_for_slave_panel = true;
		/*
		*	Set maximum brightness here. AOB needs to be modified
		*	to get real brightness setting
		*/
		mdfld_dsi_send_mcs_short_hs(sender,
				write_display_brightness, 0x90, 1,
				MDFLD_DSI_SEND_PACKAGE);
	}
	sender->work_for_slave_panel = false;
	return 0;
}
static void smd_qhd_amoled_cmd_get_mtp_set4(struct mdfld_dsi_config *dsi_config,
					u8 *elvss, u8 *white_pt_adj)
{
	static bool is_cached;
	static u8 cached_elvss = 0x08; /* init to default value per spec */
	static u8 cached_white_pt_adj = 0xff;
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int r = 0;
	u8 reg_data[2];
	u8 ver;

	if (!is_cached) {
		r = mdfld_dsi_read_mcs_hs(sender, 0xd4, reg_data, 2);
		if (r != 2) {
			DRM_ERROR("Failed to read MTP_SET4, r = %d\n", r);
		} else {
			cached_elvss = reg_data[0] & 0x3f;
			if (mdfld_mot_cmn_get_panel_cntrl_ver(sender, &ver))
				DRM_ERROR("Failed to get panel controller "
					"version\n");
			else {
				if (ver >= 1)
					cached_white_pt_adj =
						(reg_data[1] & 0xf0) >> 4;

				printk(KERN_ALERT"Read MTP_SET4, elvss = 0x%02x,"
					"white_pt = 0x%02x\n",
					cached_elvss, cached_white_pt_adj);
				is_cached = true;
			}
		}
	}
static int __dpi_enter_ulps_locked(struct mdfld_dsi_config *dsi_config, int offset)
{
	struct mdfld_dsi_hw_registers *regs = &dsi_config->regs;
	struct mdfld_dsi_hw_context *ctx = &dsi_config->dsi_hw_context;
	struct drm_device *dev = dsi_config->dev;
	struct mdfld_dsi_pkg_sender *sender
		= mdfld_dsi_get_pkg_sender(dsi_config);
	if (!sender) {
		DRM_ERROR("pkg sender is NULL\n");
		return -EINVAL;
	}

	ctx->device_ready = REG_READ(regs->device_ready_reg + offset);

	if (ctx->device_ready & DSI_POWER_STATE_ULPS_MASK) {
		DRM_ERROR("Broken ULPS states\n");
		return -EINVAL;
	}

	/*wait for all FIFOs empty*/
	mdfld_dsi_wait_for_fifos_empty(sender);

	/*inform DSI host is to be put on ULPS*/
	ctx->device_ready |= DSI_POWER_STATE_ULPS_ENTER;
	REG_WRITE(regs->device_ready_reg + offset, ctx->device_ready);

	PSB_DEBUG_ENTRY("entered ULPS state\n");
	return 0;
}
static int samsungWQHD_cmd_drv_ic_init(struct mdfld_dsi_config *dsi_config){

	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int i;

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	printk("[DISP] %s\n", __func__);

	/* HW_RST control */
	gpio_set_value_cansleep(panel_reset_gpio, 1);
	usleep_range(1000, 1500);
	gpio_set_value_cansleep(panel_reset_gpio, 0);
	usleep_range(1000, 1500);
	gpio_set_value_cansleep(panel_reset_gpio, 1);
	usleep_range(10000, 10500);
	/* HW_RST control */


	/* panel initial settings */
	mdfld_dsi_send_mcs_short_lp(sender, 0x11, 0, 0, MDFLD_DSI_SEND_PACKAGE);
	usleep_range(20000, 20100);

	for (i = 0; i < samsungWQHD_power_on_table_size; i++)
		send_mipi_cmd_mcs(sender, &samsungWQHD_power_on_table[i]);

	return 0;
}
void mdfld_dsi_dpi_set_color_mode(struct mdfld_dsi_config *dsi_config , bool on)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int err;
	u32  spk_pkg =  (on == true) ? MDFLD_DSI_DPI_SPK_COLOR_MODE_ON :
		MDFLD_DSI_DPI_SPK_COLOR_MODE_OFF;


	PSB_DEBUG_ENTRY("Turn  color mode %s  pkg value= %d...\n",
			(on ? "on" : "off"), spk_pkg);

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return ;
	}

	/*send turn on/off color mode packet*/
	err = mdfld_dsi_send_dpi_spk_pkg_hs(sender,
			spk_pkg);
	if (err) {
		DRM_ERROR("Failed to send turn on packet\n");
		return ;
	}
	PSB_DEBUG_ENTRY("Turn  color mode %s successful.\n",
			(on ? "on" : "off"));
	return;
}
Пример #19
0
static int gi_renesas_dbi_ic_init(struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_pkg_sender *sender
			= mdfld_dsi_get_pkg_sender(dsi_config);

	if (!sender) {
		DRM_ERROR("Cannot get sender\n");
		return -EINVAL;
	}

	PSB_DEBUG_ENTRY("\n");

	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_mcs_protect_on, 2, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_mcs_mem_access, 5, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_mcs_panel_driving, 9, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_disp_timming, 6, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_src_timming, 5, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_polarity_setting, 2, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_gamma_a, 25, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_gamma_b, 25, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_gamma_c, 25, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_power_setting, 17, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_vcom_setting, 5, 0);
	mdfld_dsi_send_mcs_long_hs(sender, gi_er61529_set_pixel_format, 2, 0);
	mdfld_dsi_send_mcs_long_hs(sender, gi_er61529_set_column_address, 5, 0);
	mdfld_dsi_send_mcs_long_hs(sender, gi_er61529_set_page_address, 5, 0);
	mdfld_dsi_send_mcs_long_hs(sender, gi_er61529_set_address_mode, 2, 0);
	mdfld_dsi_send_mcs_long_hs(sender, gi_er61529_set_te_scanline, 3, 0);
	mdfld_dsi_send_mcs_long_hs(sender, gi_er61529_set_tear_on, 2, 0);
	mdfld_dsi_send_gen_long_hs(sender, gi_er61529_mcs_protect_off, 2, 0);

	return 0;
}
static int orise1284a_vid_drv_ic_reset_workaround(struct mdfld_dsi_config *dsi_config) {

	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int i;

	sender->status = MDFLD_DSI_PKG_SENDER_FREE;

	mdfld_dsi_send_mcs_short_hs(sender, 0x11, 0, 0, MDFLD_DSI_SEND_PACKAGE);
	mdelay(5);
	mdfld_dsi_send_mcs_short_hs(sender, 0x29, 0, 0, MDFLD_DSI_SEND_PACKAGE);

	mdfld_dsi_send_mcs_short_hs(sender, 0x00, 0x80, 1, MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_mcs_short_hs(sender, 0xFF, 0x12, 1, MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_mcs_short_hs(sender, 0xFF, 0x84, 1, MDFLD_DSI_SEND_PACKAGE);

	mdfld_dsi_send_mcs_short_hs(sender, 0x00, 0x90, 1, MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_mcs_short_hs(sender, 0xB6, 0xB6, 1, MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_mcs_short_hs(sender, 0x00, 0x92, 1, MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_mcs_short_hs(sender, 0xB3, 0x06, 1, MDFLD_DSI_SEND_PACKAGE);

	mdfld_dsi_send_mcs_short_hs(sender, 0x00, 0x80, 1, MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_mcs_short_hs(sender, 0xFF, 0x00, 1, MDFLD_DSI_SEND_PACKAGE);
	mdfld_dsi_send_mcs_short_hs(sender, 0xFF, 0x00, 1, MDFLD_DSI_SEND_PACKAGE);

	if (sender->status == MDFLD_DSI_CONTROL_ABNORMAL) {
		printk("[DISP] %s MDFLD_DSI_CONTROL_ABNORMAL !!\n", __func__);
		return -EIO;
	}

	return 0;
}
static
int mdfld_dsi_pr2_set_brightness(struct mdfld_dsi_config *dsi_config,
		int level)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int duty_val = 0;

	PSB_DEBUG_ENTRY("level = %d\n", level);

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	duty_val = (255 * level) / 100;

	mdfld_dsi_send_gen_long_hs(sender, pr2_mcs_protect_off, 2, 0);

	/*update duty value*/
	pr2_backlight_control_2[2] = duty_val;

	if (drm_psb_enable_cabc) {
		if (level < 50) {
			pr2_backlight_control_1[1] = 0x00;
			pr2_backlight_control_1[2] = 0x0f;
			pr2_backlight_control_1[3] = 0x0f;
		} else if (level < 66) {
			/* Case 10% */
			pr2_backlight_control_1[1] = 0x01;
			pr2_backlight_control_1[2] = 0x07;
			pr2_backlight_control_1[3] = 0x07;
			pr2_backlight_control_1[6] = 0xe4;
			pr2_backlight_control_1[7] = 0xe4;
		} else if (level < 82) {
			/* Case 20% */
			pr2_backlight_control_1[1] = 0x01;
			pr2_backlight_control_1[2] = 0x0b;
			pr2_backlight_control_1[3] = 0x0b;
			pr2_backlight_control_1[6] = 0xd4;
			pr2_backlight_control_1[7] = 0xd4;
		} else {
			/* Case 30% */
			pr2_backlight_control_1[1] = 0x01;
			pr2_backlight_control_1[2] = 0x0f;
			pr2_backlight_control_1[3] = 0x0f;
			pr2_backlight_control_1[6] = 0xc8;
			pr2_backlight_control_1[7] = 0xc8;
		}

		mdfld_dsi_send_gen_long_hs(sender,
				pr2_backlight_control_1, 24, 0);
	}

	mdfld_dsi_send_gen_long_hs(sender, pr2_backlight_control_2, 8, 0);
	mdfld_dsi_send_gen_long_hs(sender, pr2_mcs_protect_on, 4, 0);

	return 0;
}
Пример #22
0
static int __mdfld_auo_dsi_power_off(struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	u8 cmd = 0;
	int err = 0;

	PSB_DEBUG_ENTRY("Turn off video mode TMD panel...\n");

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	/*enter sleep mode*/
	cmd = enter_sleep_mode;
	err = mdfld_dsi_send_dcs(sender,
			cmd,
			NULL,
			0,
			CMD_DATA_SRC_SYSTEM_MEM,
			MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("DCS 0x%x sent failed\n", cmd);
		return err;
	}

	msleep(120);

	/*set tear off*/
	cmd = set_tear_off;
	err = mdfld_dsi_send_dcs(sender,
			cmd,
			NULL,
			0,
			CMD_DATA_SRC_SYSTEM_MEM,
			MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("DCS 0x%x sent failed\n", cmd);
		return err;
	}


	/*set display off*/
	cmd = set_display_off;
	err = mdfld_dsi_send_dcs(sender,
			cmd,
			NULL,
			0,
			CMD_DATA_SRC_SYSTEM_MEM,
			MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("DCS 0x%x sent failed\n", cmd);
		return err;
	}

	return err;
}
static
int sharp25x16_cmd_drv_ic_init(struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_pkg_sender *sender
		= mdfld_dsi_get_pkg_sender(dsi_config);
	struct drm_device *dev = dsi_config->dev;
	int err = 0;
	int i;

	PSB_DEBUG_ENTRY("\n");
	if (!sender) {
		DRM_ERROR("Cannot get sender\n");
		return -EINVAL;
	}
	for (i = 0; i < 5; i++) {
		err = mdfld_dsi_send_gen_long_lp(sender, sharp_mode_set_data[i],
				3,
				MDFLD_DSI_SEND_PACKAGE);
		if (err) {
			DRM_ERROR("%s: %d: Set Mode data\n", __func__, __LINE__);
			goto ic_init_err;
		}
		REG_WRITE(MIPIA_LP_GEN_CTRL_REG, 5);
	}

	err = mdfld_dsi_send_mcs_long_lp(sender,
			sharp_clumn_addr_left,
			5, MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: Set Clumn Address\n",
		__func__, __LINE__);
		goto ic_init_err;
	}
	REG_WRITE(MIPIA_LP_GEN_CTRL_REG, 5);
	err = mdfld_dsi_send_mcs_long_lp(sender,
			sharp_page_addr_left,
			5, MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: Set Page Address\n",
		__func__, __LINE__);
		goto ic_init_err;
	}
	REG_WRITE(MIPIA_LP_GEN_CTRL_REG, 5);

	err = mdfld_dsi_send_mcs_short_lp(sender,
			set_tear_on, 0x00, 1,
			MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: Set Tear On\n",
		__func__, __LINE__);
		goto ic_init_err;
	}
	return 0;

ic_init_err:
	err = -EIO;
	return err;
}
static int mdfld_dsi_sharp10x19_drv_ic_init(struct mdfld_dsi_config *dsi_config)
{

	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int err = 0;

	if (!sender) {
		DRM_ERROR("Cannot get sender\n");
		return -EINVAL;
	}

	PSB_DEBUG_ENTRY("\n");

	err = mdfld_dsi_send_mcs_short_hs(sender,
		access_protect,
		0x4, 1 , 0);
	if (err) {
		DRM_ERROR("%s: %d: Set access_protect off\n", __func__, __LINE__);
		goto ic_init_err;
	}
	err = mdfld_dsi_send_mcs_short_hs(sender,
		0xd6,
		0x01, 1 , 0);
	if (err) {
		DRM_ERROR("%s: %d: Remove NVM reload\n", __func__, __LINE__);
		goto ic_init_err;
	}

	err = mdfld_dsi_send_mcs_short_hs(sender,
		write_ctrl_display,
		0xc, 1 , 0);
	if (err) {
		DRM_ERROR("%s: %d: Set backlight\n", __func__, __LINE__);
		goto ic_init_err;
	}

	err = mdfld_dsi_send_mcs_short_hs(sender,
		write_ctrl_cabc, dsi_config->cabc_mode, 1,
		MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: write_ctrl_cabc\n", __func__, __LINE__);
		goto ic_init_err;
	}
	err = mdfld_dsi_send_mcs_short_hs(sender,
						  set_pixel_format, 0x77, 1,
						  MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: set_pixel_format\n", __func__, __LINE__);
		goto ic_init_err;
	}

	return 0;
ic_init_err:
	err = -EIO;
	return err;

}
Пример #25
0
static int __dpi_enter_ulps_locked(struct mdfld_dsi_config *dsi_config)
{
    struct mdfld_dsi_hw_registers *regs = &dsi_config->regs;
    struct mdfld_dsi_hw_context *ctx = &dsi_config->dsi_hw_context;
    struct drm_device *dev = dsi_config->dev;
    struct mdfld_dsi_pkg_sender *sender
        = mdfld_dsi_get_pkg_sender(dsi_config);
    int retry = 5;

ulps_recovery:

    PSB_DEBUG_ENTRY("\n");
    ctx->device_ready = REG_READ(regs->device_ready_reg);

    if (ctx->device_ready & DSI_POWER_STATE_ULPS_MASK) {
        DRM_ERROR("Broken ULPS states\n");
        return -EINVAL;
    }

    if (!sender) {
        DRM_ERROR("Cannot get sender\n");
        return -EINVAL;
    }

    /* check latch out, expected to be lp11 */
    intel_dc_dsi_check_latch_out(dsi_config);

    /*wait for all FIFOs empty*/
    mdfld_dsi_wait_for_fifos_empty(sender);

    /*inform DSI host is to be put on ULPS*/
    ctx->device_ready |= (DSI_POWER_STATE_ULPS_ENTER | DSI_DEVICE_READY);
    REG_WRITE(regs->device_ready_reg, ctx->device_ready);
    mdelay(1);

    /* check latch out, expected to be lp00 */
    intel_dc_dsi_check_latch_out(dsi_config);

    if (intel_dc_dsi_wait_for_lp00(dsi_config)) {
        DRM_ERROR("faild to wait for lp00 status\n");
        DRM_ERROR("reg[0x%x] = 0x%x\n", regs->mipi_reg, REG_READ(regs->mipi_reg));

        if (retry--) {
            DRM_INFO("%s: retry enter ulps (times=%d)\n", __func__, 5-retry);
            if (__dpi_exit_ulps_locked(dsi_config)) {
                DRM_ERROR("Failed to exit ULPS\n");
            }
            goto ulps_recovery;
        }
    }

    /* set AFE hold value*/
    REG_WRITE(regs->mipi_reg,
              REG_READ(regs->mipi_reg) & (~PASS_FROM_SPHY_TO_AFE));

    DRM_INFO("%s: entered ULPS state\n", __func__);
    return 0;
}
Пример #26
0
int mdfld_dsi_dsr_update_panel_fb(struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_dsr *dsr;
	struct mdfld_dsi_pkg_sender *sender;
	int err = 0;

	if (!dsi_config) {
		DRM_ERROR("Invalid parameter\n");
		return -EINVAL;
	}

	dsr = dsi_config->dsr;

	if (!IS_ANN(dev)) {
		/*if no dsr attached, return 0*/
		if (!dsr)
			return 0;
	}

	PSB_DEBUG_ENTRY("\n");

	if (dsi_config->type == MDFLD_DSI_ENCODER_DPI)
		return 0;
	mutex_lock(&dsi_config->context_lock);

	if (!dsi_config->dsi_hw_context.panel_on) {
		PSB_DEBUG_ENTRY(
		"if screen off, update fb is not allowed\n");
		err = -EINVAL;
		goto update_fb_out;
	}

	/*no pending fb updates, go ahead to send out write_mem_start*/
	PSB_DEBUG_ENTRY("send out write_mem_start\n");
	sender = mdfld_dsi_get_pkg_sender(dsi_config);
	if (!sender) {
		DRM_ERROR("No sender\n");
		err = -EINVAL;
		goto update_fb_out;
	}

	err = mdfld_dsi_send_dcs(sender, write_mem_start,
				NULL, 0, CMD_DATA_SRC_PIPE,
				MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("Failed to send write_mem_start");
		err = -EINVAL;
		goto update_fb_out;
	}

	/*clear free count*/
	dsr->free_count = 0;

update_fb_out:
	mutex_unlock(&dsi_config->context_lock);
	return err;
}
static int ls04x_igzo_g8_drv_ic_init(struct mdfld_dsi_config *dsi_config)
{
	DRM_INFO("IGZO G8 panel detected!\n");
	pwm_width = 8;
	u8 data[16];
	struct mdfld_dsi_pkg_sender *sender
				= mdfld_dsi_get_pkg_sender(dsi_config);
	mdfld_dsi_read_gen_hs(sender,
			ls04x_vcom_setting_igzo_g8[0], 0, 1, data, 11);
	if (DEFAULT_VCOM_SETTING == data[4])
		return handle_dsi_init_commands(
					mdfld_dsi_get_pkg_sender(dsi_config),
					igzo_g8_init_commands);
	else
		return handle_dsi_init_commands(
					mdfld_dsi_get_pkg_sender(dsi_config),
					programed_igzo_g8_init_commands);
}
static int mdfld_dsi_jdi_power_off(struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int err;

	PSB_DEBUG_ENTRY("\n");

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	/*send SHUT_DOWN packet */
	err = mdfld_dsi_send_dpi_spk_pkg_hs(sender,
			MDFLD_DSI_DPI_SPK_SHUT_DOWN);
	if (err) {
		DRM_ERROR("Failed to send turn off packet\n");
		goto power_off_err;
	}
	/* According HW DSI spec, need to wait for 100ms. */
	msleep(100);

	/* Set Display off */
	err = mdfld_dsi_send_mcs_short_hs(sender, set_display_off, 0, 0,
			MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: Set Display On\n", __func__, __LINE__);
		goto power_off_err;
	}
	/* Wait for 1 frame after set_display_on. */
	msleep(20);

	/* Sleep In */
	err = mdfld_dsi_send_mcs_short_hs(sender, enter_sleep_mode, 0, 0,
			MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: Exit Sleep Mode\n", __func__, __LINE__);
		goto power_off_err;
	}
	/* Wait for 3 frames after enter_sleep_mode. */
	msleep(51);

	/* Can not poweroff VPROG2, because many other module related to
	 * this power supply, such as PSH sensor. */
	/*__vpro2_power_ctrl(false);*/
	if (bias_en_gpio)
		gpio_set_value_cansleep(bias_en_gpio, 0);

	return 0;

power_off_err:
	err = -EIO;
	return err;
}
static
int sharp25x16_cmd_power_on(
	struct mdfld_dsi_config *dsi_config)
{

	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int err = 0;

	PSB_DEBUG_ENTRY("\n");
	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}
	err = mdfld_dsi_send_mcs_short_hs(sender,
		set_address_mode, 0x0, 1,
		MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: Set Address Mode\n",
		__func__, __LINE__);
		goto power_err;
	}
//	usleep_range(20000, 20100);

	err = mdfld_dsi_send_mcs_short_hs(sender,
			set_pixel_format, 0x77, 1,
			MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: Set Pixel format\n",
		__func__, __LINE__);
		goto power_err;
	}

	/* Sleep Out */
	err = mdfld_dsi_send_mcs_short_hs(sender, exit_sleep_mode, 0, 0,
			MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: Exit Sleep Mode\n", __func__, __LINE__);
		goto power_err;
	}

	msleep(20);
	/* Set Display on 0x29 */
	err = mdfld_dsi_send_mcs_short_hs(sender, set_display_on, 0, 0,
			MDFLD_DSI_SEND_PACKAGE);
	if (err) {
		DRM_ERROR("%s: %d: Set Display On\n", __func__, __LINE__);
		goto power_err;
	}
	msleep(150);

power_err:
	return err;
}
static
int mdfld_dsi_pr2_power_on(struct mdfld_dsi_config *dsi_config)
{
	struct mdfld_dsi_pkg_sender *sender =
		mdfld_dsi_get_pkg_sender(dsi_config);
	int err;

	PSB_DEBUG_ENTRY("\n");

	if (!sender) {
		DRM_ERROR("Failed to get DSI packet sender\n");
		return -EINVAL;
	}

	/*send TURN_ON packet*/
	err = mdfld_dsi_send_dpi_spk_pkg_hs(sender,
			MDFLD_DSI_DPI_SPK_TURN_ON);
	if (err) {
		DRM_ERROR("Failed to send turn on packet\n");
		return err;
	}
	/**
	 * According HW DSI spec, here need wait for 100ms. This is
	 * not necessary as the code is anyway sleeping 141 ms later
	 * in this function
	 */

	mdfld_dsi_send_gen_long_hs(sender, pr2_mcs_protect_off, 2, 0);
	/*change power state*/
	mdfld_dsi_send_mcs_long_hs(sender, pr2_exit_sleep_mode, 4, 0);

	/*120ms delay is needed between enter and exit sleep mode per spec*/
	msleep(120);

	/*enable PWMON*/
	pr2_backlight_control_2[1] |= 0x01;
	mdfld_dsi_send_mcs_long_hs(sender,
			pr2_backlight_control_2, 8, 0);

	/*set display on*/
	mdfld_dsi_send_mcs_long_hs(sender, pr2_set_display_on, 4, 0);
	/* Per panel spec, 21ms delay is needed */
	msleep(21);

	/*Enable BLON , CABC*/
	if (drm_psb_enable_cabc) {
		pr2_backlight_control_1[1] |= 0x01;
		mdfld_dsi_send_gen_long_hs(sender,
				pr2_backlight_control_1, 24, 0);
		DRM_INFO("%s: enable pr2 cabc\n", __func__);
	}

	return 0;
}