diff options
| author | mattis fjallstrom <mattis@acm.org> | 2015-05-21 12:00:33 -0700 | 
|---|---|---|
| committer | mattis fjallstrom <mattis@acm.org> | 2015-05-21 13:24:30 -0700 | 
| commit | 7d990a059acf5eb46ae99c058fc9911cbdce131d (patch) | |
| tree | ac9531b3ff2b2670dabc84c248a1770c84109586 /drivers/video/omap2/displays/panel-minnow.c | |
| parent | e8980e2a6a7392ae5a1f882d1ba01e03ac83f899 (diff) | |
| parent | 89fdc2c4bb83fff36199cd883a27efb317f02037 (diff) | |
| download | olio-linux-3.10-7d990a059acf5eb46ae99c058fc9911cbdce131d.tar.xz olio-linux-3.10-7d990a059acf5eb46ae99c058fc9911cbdce131d.zip  | |
Merge branch 'android-omap-minnow-3.10-lollipop-wear-release' of https://android.googlesource.com/kernel/omap into mattis_devmattis_dev
Change-Id: I46165dd7747b9b6289eb44cb96cbef2de46c10ba
Diffstat (limited to 'drivers/video/omap2/displays/panel-minnow.c')
| -rw-r--r-- | drivers/video/omap2/displays/panel-minnow.c | 145 | 
1 files changed, 129 insertions, 16 deletions
diff --git a/drivers/video/omap2/displays/panel-minnow.c b/drivers/video/omap2/displays/panel-minnow.c index 8d127ae401f..d1014b0af1d 100644 --- a/drivers/video/omap2/displays/panel-minnow.c +++ b/drivers/video/omap2/displays/panel-minnow.c @@ -302,6 +302,8 @@ struct minnow_panel_data {  	int id_panel;  	int x_offset;  	int y_offset; +	int xres_um; +	int yres_um;  	int reset_ms;  	int release_ms; @@ -439,6 +441,27 @@ static void minnow_panel_sync_resume_mlocked(struct minnow_panel_data *mpd)  #endif  #ifdef CONFIG_WAKEUP_SOURCE_NOTIFY +static char *action_to_str(unsigned long action) +{ +	switch (action) { +	case DISPLAY_WAKE_EVENT_POWERKEY: +		return "power_key"; +	case DISPLAY_WAKE_EVENT_TOUCH: +		return "touch"; +	case DISPLAY_WAKE_EVENT_GESTURE: +		return "gesture_wrist"; +	case DISPLAY_WAKE_EVENT_GESTURE_VIEWON: +		return "gesture_view_on"; +	case DISPLAY_WAKE_EVENT_GESTURE_VIEWOFF: +		return "gesture_view_off"; +	case DISPLAY_WAKE_EVENT_DOCKON: +		return "dock_on"; +	case DISPLAY_WAKE_EVENT_DOCKOFF: +		return "dock_off"; +	} +	return "unsupported"; +} +  static int omapdss_displayenable_notify(struct notifier_block *self,  			unsigned long action, void *dev)  { @@ -448,7 +471,8 @@ static int omapdss_displayenable_notify(struct notifier_block *self,  	if (GET_WAKEUP_EVENT_TYPE(action) != WAKEUP_DISPLAY)  		return NOTIFY_OK; -	dev_info(&mpd->dssdev->dev, "%s, action is %lu", __func__, action); +	dev_info(&mpd->dssdev->dev, "%s, action is %lu-%s", +		 __func__, action, action_to_str(action));  	switch (action) {  	case DISPLAY_WAKE_EVENT_POWERKEY: @@ -1420,6 +1444,14 @@ static void minnow_panel_get_resolution(struct omap_dss_device *dssdev,  	*yres = dssdev->panel.timings.y_res;  } +static void minnow_panel_get_dimensions(struct omap_dss_device *dssdev, +		u32 *xres, u32 *yres) +{ +	struct minnow_panel_data *mpd = dev_get_drvdata(&dssdev->dev); +	*xres = mpd->xres_um; +	*yres = mpd->yres_um; +} +  static ssize_t minnow_panel_errors_show(struct device *dev,  	struct device_attribute *attr, char *buf)  { @@ -1874,6 +1906,49 @@ static ssize_t minnow_panel_store_interactivemode(struct device *dev,  	return r ? r : count;  } +static ssize_t minnow_panel_show_smartambient(struct device *dev, +	struct device_attribute *attr, char *buf) +{ +	struct omap_dss_device *dssdev = to_dss_device(dev); +	struct minnow_panel_data *mpd = dev_get_drvdata(&dssdev->dev); +	unsigned t; + +	t = mpd->smart_ambient; + +	return snprintf(buf, PAGE_SIZE, "%u\n", t); +} + +static ssize_t minnow_panel_store_smartambient(struct device *dev, +	struct device_attribute *attr, const char *buf, size_t count) +{ +	struct omap_dss_device *dssdev = to_dss_device(dev); +	struct minnow_panel_data *mpd = dev_get_drvdata(&dssdev->dev); +	unsigned long t; +	int r; +	bool enable; + +	r = kstrtoul(buf, 10, &t); +	if (!r) { +		mutex_lock(&mpd->lock); +		enable = !!t; +		if (mpd->state != DISPLAY_ENABLE) { +			dev_err(&dssdev->dev, "%s failed as display is not enabled\n", +				__func__); +			r = -EBUSY; +		} else if (mpd->smart_ambient != enable) { +			mpd->smart_ambient = enable; +		} +		mutex_unlock(&mpd->lock); +		if (r) +			dev_err(&dssdev->dev, "setting smartambient_status to %ld failed %d\n", +				t, r); +		else +			dev_dbg(&dssdev->dev, "setting smartambient_status to %ld succeeded\n", +				t); +	} + +	return r ? r : count; +}  static ssize_t minnow_panel_show_ambient_timeout(struct device *dev,  	struct device_attribute *attr, char *buf)  { @@ -2050,6 +2125,9 @@ static DEVICE_ATTR(init_data, S_IRUGO | S_IWUSR,  static DEVICE_ATTR(interactivemode, S_IRUGO | S_IWUSR,  		   minnow_panel_show_interactivemode,  		   minnow_panel_store_interactivemode); +static DEVICE_ATTR(smartambient, S_IRUSR | S_IWUSR, +		   minnow_panel_show_smartambient, +		   minnow_panel_store_smartambient);  static DEVICE_ATTR(ambient_timeout, S_IRUGO | S_IWUSR,  		   minnow_panel_show_ambient_timeout,  		   minnow_panel_store_ambient_timeout); @@ -2076,6 +2154,7 @@ static struct attribute *minnow_panel_attrs[] = {  #endif  #ifdef	CONFIG_HAS_AMBIENTMODE  	&dev_attr_interactivemode.attr, +	&dev_attr_smartambient.attr,  	&dev_attr_ambient_timeout.attr,  #endif  #ifdef	PANEL_PERF_TIME @@ -2409,6 +2488,15 @@ static int minnow_panel_dt_init(struct minnow_panel_data *mpd)  			mpd->dsi_config.lp_clk_max);  	} +	mpd->xres_um = 0; +	mpd->yres_um = 0; +	if (!of_property_read_u32_array(dt_node, "panel_size_um", range, 2)) { +		mpd->xres_um = range[0]; +		mpd->yres_um = range[1]; +		DTINFO("physical panel width = %d um, height = %d um\n", +			mpd->xres_um, mpd->yres_um); +	} +  	return 0;  } @@ -2453,6 +2541,7 @@ static int minnow_panel_probe(struct omap_dss_device *dssdev)  	mpd->dssdev = dssdev;  	mpd->first_enable = true;  	mpd->m4_state = DISPLAY_ENABLE; +	mpd->interactive = true;  	r = minnow_panel_dt_init(mpd);  	if (r) @@ -3030,8 +3119,9 @@ static int minnow_panel_enable_mlocked(struct minnow_panel_data *mpd)  	bool update;  	int r = 0; -	dev_info(&dssdev->dev, "%s: current state = %d\n", -		 __func__, dssdev->state); +	dev_info(&dssdev->dev, "%s: current display is %s\n", __func__, +		 dssdev->state == OMAP_DSS_DISPLAY_DISABLED +		 ? "disabled" : "enabled");  	if (dssdev->state == OMAP_DSS_DISPLAY_DISABLED) {  		wake_lock(&mpd->wake_lock); @@ -3067,8 +3157,9 @@ static void minnow_panel_disable_mlocked(struct minnow_panel_data *mpd)  {  	struct omap_dss_device *dssdev = mpd->dssdev; -	dev_info(&dssdev->dev, "%s: current state = %d\n", -		 __func__, dssdev->state); +	dev_info(&dssdev->dev, "%s: current display is %s\n", __func__, +		 dssdev->state == OMAP_DSS_DISPLAY_DISABLED +		 ? "disabled" : "enabled");  	wake_lock(&mpd->wake_lock);  	mpd->early_inited = false; @@ -3091,7 +3182,6 @@ static void minnow_panel_disable_mlocked(struct minnow_panel_data *mpd)  static void minnow_panel_sync_display_status_mlocked(  	struct minnow_panel_data *mpd)  { -	struct m4sensorhub_data *m4sensorhub;  	enum display_state m4_state = mpd->state;  	/* special case for dock mode, set to DISPLAY_ENABLE  	 * to block all wakeup gestures @@ -3104,21 +3194,19 @@ static void minnow_panel_sync_display_status_mlocked(  	/* be safety to sync resume states first */  	minnow_panel_sync_resume_mlocked(mpd); -	m4sensorhub = m4sensorhub_client_get_drvdata(); -	if (m4sensorhub->mode != NORMALMODE) { +	if (m4sensorhub_get_current_mode() != NORMALMODE) {  		dev_err(&mpd->dssdev->dev,  			"M4 is not ready, unable to set screen status(%d)\n",  			m4_state);  		return;  	} -	if (m4sensorhub_reg_write_1byte(m4sensorhub, -					M4SH_REG_USERSETTINGS_SCREENSTATUS, -					m4_state, 0xFF) != 1) { + +	if (m4sensorhub_extern_set_display_status(m4_state) < 0) {  		dev_err(&mpd->dssdev->dev, -			"Unable to set screen status(%d) to M4\n", -			m4_state); +			"Unable to set screen status(%d) to M4\n", m4_state);  		return;  	} +  	dev_dbg(&mpd->dssdev->dev,  		"Set screen status(%d) to M4 success!\n", m4_state);  	mpd->m4_state = m4_state; @@ -3145,13 +3233,32 @@ static void led_set_dim_brightness(struct device *dev)  }  #endif /* CONFIG_HAS_AMBIENTMODE */ +static char *state_to_str(enum display_state state) +{ +	switch (state) { +	case DISPLAY_DISABLE: +		return "normal_off"; +	case DISPLAY_ENABLE: +		return "normal_on"; +#ifdef	CONFIG_HAS_AMBIENTMODE +	case DISPLAY_AMBIENT_OFF: +		return "ambient_off"; +	case DISPLAY_AMBIENT_ON: +		return "ambient_on"; +#endif +	} +	return "unknown???"; +} +  static int minnow_panel_change_state_mlocked(struct minnow_panel_data *mpd,  					     int state)  {  	int r = 0;  	dev_info(&mpd->dssdev->dev, -		 "change state %d ==> %d\n", mpd->state, state); +		 "change state %d(%s) ==> %d(%s)\n", +		 mpd->state, state_to_str(mpd->state), +		 state, state_to_str(state));  	/* already in state, return success */  	if (state == mpd->state) { @@ -3364,7 +3471,7 @@ static void minnow_panel_te_timeout_work_callback(struct work_struct *work)  static int minnow_panel_enable(struct omap_dss_device *dssdev)  {  	struct minnow_panel_data *mpd = dev_get_drvdata(&dssdev->dev); -	int r; +	int r, state;  	mutex_lock(&mpd->lock);  #ifdef	CONFIG_WAKEUP_SOURCE_NOTIFY @@ -3374,7 +3481,12 @@ static int minnow_panel_enable(struct omap_dss_device *dssdev)  		cancel_delayed_work(&mpd->early_init_timeout_work);  	}  #endif -	r = minnow_panel_change_state_mlocked(mpd, DISPLAY_ENABLE); +	state = DISPLAY_ENABLE; +#ifdef	CONFIG_HAS_AMBIENTMODE +	if (!mpd->interactive) +		state = DISPLAY_AMBIENT_ON; +#endif +	r = minnow_panel_change_state_mlocked(mpd, state);  	mutex_unlock(&mpd->lock);  	return r;  } @@ -3726,6 +3838,7 @@ static struct omap_dss_driver minnow_panel_driver = {  	.sync		= minnow_panel_sync,  	.get_resolution	= minnow_panel_get_resolution, +	.get_dimensions	= minnow_panel_get_dimensions,  	.get_recommended_bpp = omapdss_default_get_recommended_bpp,  	.enable_te	= minnow_panel_enable_te,  |