struct work_struct switch_source;
struct notifier_block reboot_nb;
+ /* Shadow register for the DCON_REG_MODE register */
+ u8 disp_mode;
+
/* Current output type; true == mono, false == color */
bool mono:1;
+ bool asleep:1;
};
/* I2C structures */
/* Desired source */
static int dcon_pending;
-/* Current sleep status (not yet implemented) */
-static int dcon_sleep_val = DCON_ACTIVE;
-
-/* Shadow register for the DCON_REG_MODE register */
-static unsigned short dcon_disp_mode;
-
/* Variables used during switches */
static int dcon_switched;
static struct timespec dcon_irq_time;
/* Colour swizzle, AA, no passthrough, backlight */
if (is_init) {
- dcon_disp_mode = MODE_PASSTHRU | MODE_BL_ENABLE | MODE_CSWIZZLE;
+ dcon->disp_mode = MODE_PASSTHRU | MODE_BL_ENABLE |
+ MODE_CSWIZZLE;
if (useaa)
- dcon_disp_mode |= MODE_COL_AA;
+ dcon->disp_mode |= MODE_COL_AA;
}
- i2c_smbus_write_word_data(client, DCON_REG_MODE, dcon_disp_mode);
+ i2c_smbus_write_word_data(client, DCON_REG_MODE, dcon->disp_mode);
/* Set the scanline to interrupt on during resume */
/* Purposely turn off the backlight when we go to level 0 */
if (bl_val == 0) {
- dcon_disp_mode &= ~MODE_BL_ENABLE;
- dcon_write(dcon, DCON_REG_MODE, dcon_disp_mode);
- } else if (!(dcon_disp_mode & MODE_BL_ENABLE)) {
- dcon_disp_mode |= MODE_BL_ENABLE;
- dcon_write(dcon, DCON_REG_MODE, dcon_disp_mode);
+ dcon->disp_mode &= ~MODE_BL_ENABLE;
+ dcon_write(dcon, DCON_REG_MODE, dcon->disp_mode);
+ } else if (!(dcon->disp_mode & MODE_BL_ENABLE)) {
+ dcon->disp_mode |= MODE_BL_ENABLE;
+ dcon_write(dcon, DCON_REG_MODE, dcon->disp_mode);
}
}
dcon->mono = enable_mono;
if (enable_mono) {
- dcon_disp_mode &= ~(MODE_CSWIZZLE | MODE_COL_AA);
- dcon_disp_mode |= MODE_MONO_LUMA;
+ dcon->disp_mode &= ~(MODE_CSWIZZLE | MODE_COL_AA);
+ dcon->disp_mode |= MODE_MONO_LUMA;
} else {
- dcon_disp_mode &= ~(MODE_MONO_LUMA);
- dcon_disp_mode |= MODE_CSWIZZLE;
+ dcon->disp_mode &= ~(MODE_MONO_LUMA);
+ dcon->disp_mode |= MODE_CSWIZZLE;
if (useaa)
- dcon_disp_mode |= MODE_COL_AA;
+ dcon->disp_mode |= MODE_COL_AA;
}
- dcon_write(dcon, DCON_REG_MODE, dcon_disp_mode);
+ dcon_write(dcon, DCON_REG_MODE, dcon->disp_mode);
return 0;
}
* DCONLOAD works in a sleep and account for it accordingly
*/
-static void dcon_sleep(struct dcon_priv *dcon, int state)
+static void dcon_sleep(struct dcon_priv *dcon, bool sleep)
{
int x;
/* Turn off the backlight and put the DCON to sleep */
- if (state == dcon_sleep_val)
+ if (dcon->asleep == sleep)
return;
if (!olpc_board_at_least(olpc_board(0xc2)))
return;
- if (state == DCON_SLEEP) {
+ if (sleep) {
x = 0;
x = olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 0);
if (x)
printk(KERN_WARNING "olpc-dcon: unable to force dcon "
"to power down: %d!\n", x);
else
- dcon_sleep_val = state;
+ dcon->asleep = sleep;
} else {
/* Only re-enable the backlight if the backlight value is set */
if (bl_val != 0)
- dcon_disp_mode |= MODE_BL_ENABLE;
+ dcon->disp_mode |= MODE_BL_ENABLE;
x = dcon_bus_stabilize(dcon, 1);
if (x)
printk(KERN_WARNING "olpc-dcon: unable to reinit dcon"
" hardware: %d!\n", x);
else
- dcon_sleep_val = state;
+ dcon->asleep = sleep;
/* Restore backlight */
dcon_set_backlight_hw(dcon, bl_val);
printk("dcon_source_switch to CPU\n");
/* Enable the scanline interrupt bit */
if (dcon_write(dcon, DCON_REG_MODE,
- dcon_disp_mode | MODE_SCAN_INT))
+ dcon->disp_mode | MODE_SCAN_INT))
printk(KERN_ERR
"olpc-dcon: couldn't enable scanline interrupt!\n");
else {
printk(KERN_ERR "olpc-dcon: Timeout entering CPU mode; expect a screen glitch.\n");
/* Turn off the scanline interrupt */
- if (dcon_write(dcon, DCON_REG_MODE, dcon_disp_mode))
+ if (dcon_write(dcon, DCON_REG_MODE, dcon->disp_mode))
printk(KERN_ERR "olpc-dcon: couldn't disable scanline interrupt!\n");
/*
static ssize_t dcon_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%4.4X\n", dcon_disp_mode);
+ struct dcon_priv *dcon = dev_get_drvdata(dev);
+ return sprintf(buf, "%4.4X\n", dcon->disp_mode);
}
static ssize_t dcon_sleep_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- return sprintf(buf, "%d\n", dcon_sleep_val);
+ struct dcon_priv *dcon = dev_get_drvdata(dev);
+ return sprintf(buf, "%d\n", dcon->asleep ? 1 : 0);
}
static ssize_t dcon_freeze_show(struct device *dev,
if (_strtoul(buf, count, &output))
return -EINVAL;
- dcon_sleep(dev_get_drvdata(dev), output ? DCON_SLEEP : DCON_ACTIVE);
+ dcon_sleep(dev_get_drvdata(dev), output ? true : false);
return count;
}
if (((event != FB_EVENT_BLANK) && (event != FB_EVENT_CONBLANK)) ||
ignore_fb_events)
return 0;
- dcon_sleep(dcon, (*blank) ? DCON_SLEEP : DCON_ACTIVE);
+ dcon_sleep(dcon, *blank ? true : false);
return 0;
}
{
struct dcon_priv *dcon = i2c_get_clientdata(client);
- if (dcon_sleep_val == DCON_ACTIVE) {
+ if (!dcon->asleep) {
/* Set up the DCON to have the source */
dcon_set_source_sync(dcon, DCON_SOURCE_DCON);
}
{
struct dcon_priv *dcon = i2c_get_clientdata(client);
- if (dcon_sleep_val == DCON_ACTIVE) {
+ if (!dcon->asleep) {
dcon_bus_stabilize(dcon, 0);
dcon_set_source(dcon, DCON_SOURCE_CPU);
}