static int mecha_auo_panel_init(struct msm_lcdc_panel_ops *ops)
{
	LCMDBG("\n");

	mutex_lock(&panel_lock);
	mecha_auo_panel_power(1);
	lcm_auo_write_seq(auo_init_seq, ARRAY_SIZE(auo_init_seq));
	lcm_auo_write_seq(auo_gamma_normal_seq, ARRAY_SIZE(auo_gamma_normal_seq));

	mutex_unlock(&panel_lock);
	return 0;
}
static int spade_auo_panel_shutdown(struct msm_lcdc_panel_ops *ops)
{
        lcm_auo_write_seq(auo_uninit_seq, ARRAY_SIZE(auo_uninit_seq));
        spade_auo_panel_power(0);

	return 0;
}
/*----------------------------------------------------------------------------*/
int spade_panel_sleep_in(void)
{
	int ret;

	LCMDBG(", screen=%s\n", screen_on ? "on" : "off");
	if (screen_on)
		return 0;

	mutex_lock(&panel_lock);
	switch (panel_type) {
		case PANEL_AUO:
			spade_auo_panel_power(1);
			lcm_auo_write_seq(auo_sleep_in_seq,
				ARRAY_SIZE(auo_sleep_in_seq));
			ret = 0;
			break;
		case PANEL_SHARP:
			spade_sharp_panel_power(1);
			lcm_sharp_write_seq(sharp_uninit_seq,
				ARRAY_SIZE(sharp_uninit_seq));
			ret = 0;
			break;
		default:
			ret = -EINVAL;
			break;
	}
	mutex_unlock(&panel_lock);
	return ret;
}
static int spade_auo_panel_refresh_disable(struct msm_lcdc_panel_ops *ops)
{
	mutex_lock(&panel_lock);
        lcm_auo_write_seq(auo_refresh_out_seq, ARRAY_SIZE(auo_refresh_out_seq));
	mutex_unlock(&panel_lock);

        return 0;
}
static int mecha_auo_panel_refresh_enable(struct msm_lcdc_panel_ops *ops)
{
	mutex_lock(&panel_lock);
        lcm_auo_write_seq(auo_refresh_in_seq, ARRAY_SIZE(auo_refresh_in_seq));
	mutex_unlock(&panel_lock);

        return 0;
}
static int mecha_auo_panel_blank(struct msm_lcdc_panel_ops *ops)
{
	LCMDBG("\n");
	mutex_lock(&panel_lock);
	lcm_auo_write_seq(auo_blank_seq, ARRAY_SIZE(auo_blank_seq));
	mutex_unlock(&panel_lock);
	return 0;
}
static int spade_auo_n90_panel_init(struct msm_lcdc_panel_ops *ops)
{
	LCMDBG("\n");

	mutex_lock(&panel_lock);
	spade_auo_panel_power(1);
	lcm_auo_write_seq(auo_n90_init_seq, ARRAY_SIZE(auo_n90_init_seq));
	mutex_unlock(&panel_lock);
	return 0;
}
static int spade_auo_n90_panel_blank(struct msm_lcdc_panel_ops *ops)
{
	LCMDBG("\n");
	spade_adjust_backlight(0);
	atomic_set(&lcm_init_done, 0);
	mutex_lock(&panel_lock);
	lcm_auo_write_seq(auo_n90_uninit_seq, ARRAY_SIZE(auo_n90_uninit_seq));
	mutex_unlock(&panel_lock);

	return 0;
}
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 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;
}