static int mecha_auo_panel_unblank(struct msm_lcdc_panel_ops *ops)
{
	LCMDBG("\n");
	if (color_enhancement == 0) {
		mecha_mdp_color_enhancement(mdp_pdata.mdp_dev);
		color_enhancement = 1;
	}
	mutex_lock(&panel_lock);
	qspi_send_16bit(0x1, 0x51);
	qspi_send_16bit(0x0, 0x00);
	qspi_send_16bit(0x2, last_val);
	lcm_auo_write_seq(auo_turn_on_backlight, ARRAY_SIZE(auo_turn_on_backlight));
	mutex_unlock(&panel_lock);
	return 0;
}
static int lcm_auo_write_seq(struct lcm_cmd *cmd_table, unsigned size)
{
        int i;

        for (i = 0; i < size; i++) {
		if (cmd_table[i].cmd == LCM_MDELAY) {
			hr_msleep(cmd_table[i].data);
			continue;
		}
		qspi_send_16bit(cmd_table[i].cmd, cmd_table[i].data);
	}
        return 0;
}
Exemplo n.º 3
0
static int panel_icm_thread(void *data)
{
	struct mdp_lcdc_info *lcdc;
	int rc;
	unsigned long irq_flags = 0;

	lcdc = data;
	while (1) {
		rc = wait_event_timeout(panel_update_wait_queue, icm_check_panel_update() == 1, PANEL_ENTER_IDLE_TIMEOUT);
		ICM_DBG("ICM Thread:wake up rc=%d \n", rc);
		mutex_lock(&panel_icm->icm_lock);
		if (rc == 0 && icm_check_panel_update() != 1) {/* wait_timeout */
			ICM_DBG("EnterICM: icm_mode=%d icm_doable=%d \n", panel_icm->icm_mode, panel_icm->icm_doable);
			if (panel_icm->icm_mode == false && panel_icm->icm_doable == true) {

				qspi_send_16bit(0x1, 0x3B);
				qspi_send_16bit(0x0, 0x00);
				qspi_send_16bit(0x2, 0x13);
				panel_icm->icm_mode = true;
				msleep(PANEL_IDLE_STABLE_TIMEOUT);

				mdp_writel(lcdc->mdp, 0, MDP_LCDC_EN);
				clk_disable(lcdc->pad_pclk);
				clk_disable(lcdc->pclk);
				clk_disable(lcdc->mdp_clk);
				pr_info("EnterICM: enter ICM MODE done!!!\n");
			}
		} else {/* get update event, no timeout */
			ICM_DBG("Leave ICM: icm_mode=%d icm_doable=%d \n", panel_icm->icm_mode, panel_icm->icm_doable);
			if (panel_icm->icm_mode == true && panel_icm->icm_doable == true) {
				clk_enable(lcdc->mdp_clk);
				clk_enable(lcdc->pclk);
				clk_enable(lcdc->pad_pclk);
				mdp_writel(lcdc->mdp, 1, MDP_LCDC_EN);

				qspi_send_16bit(0x1, 0x3B);
				qspi_send_16bit(0x0, 0x00);
				qspi_send_16bit(0x2, 0x03);
				panel_icm->icm_mode = false;
				pr_info("LeaveICM: leave ICM MODE done !!!\n");
			}
			spin_lock_irqsave(&panel_icm->lock, irq_flags);
			panel_icm->panel_update = 0;
			spin_unlock_irqrestore(&panel_icm->lock, irq_flags);
		}
		mutex_unlock(&panel_icm->icm_lock);
	} /* end while */
	return 0;
}
static void mecha_brightness_set(struct led_classdev *led_cdev,
		enum led_brightness val)
{
	struct spi_msg set_brightness = {
                .cmd = 0x51,
                .len = 1,
                .data = (unsigned char *)&val,
	};
	uint8_t shrink_br;

	mutex_lock(&panel_lock);
	if (val < 30)
		shrink_br = 8;
	else if ((val >= 30) && (val <= 143))
		shrink_br = 151 * (val - 30) / 113 + 8;
	else
		shrink_br = 96 * (val - 143) / 112 + 159;

	if (panel_type == PANEL_AUO) {
		qspi_send_16bit(0x1, 0x51);
		qspi_send_16bit(0x0, 0x00);
		qspi_send_16bit(0x2, shrink_br);
	} else {
		set_brightness.data = (unsigned char *)&shrink_br;
		qspi_send_9bit(&set_brightness);
	}
	last_val = shrink_br;
	mutex_unlock(&panel_lock);
}

static int mecha_cabc_switch(int on)
{

	if (test_bit(CABC_STATE, &status) == on)
               return 1;

	if (on) {
		printk(KERN_DEBUG "turn on CABC\n");
		set_bit(CABC_STATE, &status);
		mutex_lock(&panel_lock);
		if (panel_type == PANEL_AUO)
			lcm_auo_write_seq(auo_enable_cabc, ARRAY_SIZE(auo_enable_cabc));
		else
			lcm_sharp_write_seq(sharp_enable_cabc, ARRAY_SIZE(sharp_enable_cabc));
		mutex_unlock(&panel_lock);
	} else {
		printk(KERN_DEBUG "turn off CABC\n");
		clear_bit(CABC_STATE, &status);
		mutex_lock(&panel_lock);
		if (panel_type == PANEL_AUO)
			lcm_auo_write_seq(auo_disable_cabc, ARRAY_SIZE(auo_disable_cabc));
		else
			lcm_sharp_write_seq(sharp_disable_cabc, ARRAY_SIZE(sharp_disable_cabc));
		mutex_unlock(&panel_lock);
	}
	return 1;
}

static ssize_t
auto_backlight_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t
auto_backlight_store(struct device *dev, struct device_attribute *attr,
               const char *buf, size_t count);
#define CABC_ATTR(name) __ATTR(name, 0644, auto_backlight_show, auto_backlight_store)

static struct device_attribute auto_attr = CABC_ATTR(auto);
static ssize_t
auto_backlight_show(struct device *dev, struct device_attribute *attr, char *buf)
{
	int i = 0;

	i += scnprintf(buf + i, PAGE_SIZE - 1, "%d\n",
				test_bit(CABC_STATE, &status));
	return i;
}