#include <linux/backlight.h>
#include <linux/device.h>
#include <linux/notifier.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
#include <linux/ctype.h>
#include <linux/reboot.h>
#include <asm/tsc.h>
/* Variables used during switches */
static int dcon_switched;
static struct timespec dcon_irq_time;
-static struct timespec dcon_load_time;
+static struct timespec dcon_load_time;
static DECLARE_WAIT_QUEUE_HEAD(dcon_wait_queue);
static unsigned short normal_i2c[] = { 0x0d, I2C_CLIENT_END };
-#define dcon_write(reg,val) i2c_smbus_write_word_data(dcon_client,reg,val)
-#define dcon_read(reg) i2c_smbus_read_word_data(dcon_client,reg)
+#define dcon_write(reg, val) i2c_smbus_write_word_data(dcon_client, reg, val)
+#define dcon_read(reg) i2c_smbus_read_word_data(dcon_client, reg)
/* The current backlight value - this saves us some smbus traffic */
static int bl_val = -1;
if (is_init) {
printk(KERN_INFO "olpc-dcon: Discovered DCON version %x\n",
ver & 0xFF);
- if ((rc = pdata->init()) != 0) {
+ rc = pdata->init();
+ if (rc != 0) {
printk(KERN_ERR "olpc-dcon: Unable to init.\n");
goto err;
}
i2c_smbus_write_word_data(client, 0x0b, 0x007a);
i2c_smbus_write_word_data(client, 0x36, 0x025c);
i2c_smbus_write_word_data(client, 0x37, 0x025e);
-
+
/* Initialise SDRAM */
i2c_smbus_write_word_data(client, 0x3b, 0x002b);
i2c_smbus_write_word_data(client, 0x41, 0x0101);
i2c_smbus_write_word_data(client, 0x42, 0x0101);
- }
- else if (!noinit) {
+ } else if (!noinit) {
/* SDRAM setup/hold time */
i2c_smbus_write_word_data(client, 0x3a, 0xc040);
i2c_smbus_write_word_data(client, 0x41, 0x0000);
power_up:
if (is_powered_down) {
x = 1;
- if ((x = olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 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 up: %d!\n", x);
return x;
}
msleep(10); /* we'll be conservative */
}
-
+
pdata->bus_stabilize_wiggle();
for (x = -1, timeout = 50; timeout && x < 0; timeout--) {
if (arg == DCON_OUTPUT_MONO) {
dcon_disp_mode &= ~(MODE_CSWIZZLE | MODE_COL_AA);
dcon_disp_mode |= MODE_MONO_LUMA;
- }
- else {
+ } else {
dcon_disp_mode &= ~(MODE_MONO_LUMA);
dcon_disp_mode |= MODE_CSWIZZLE;
if (useaa)
if (state == DCON_SLEEP) {
x = 0;
- if ((x = olpc_ec_cmd(0x26, (unsigned char *) &x, 1, NULL, 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;
- }
- else {
+ } else {
/* Only re-enable the backlight if the backlight value is set */
if (bl_val != 0)
dcon_disp_mode |= MODE_BL_ENABLE;
-
- if ((x=dcon_bus_stabilize(dcon_client, 1)))
+ x = dcon_bus_stabilize(dcon_client, 1);
+ if (x)
printk(KERN_WARNING "olpc-dcon: unable to reinit dcon"
" hardware: %d!\n", x);
else
}
/* the DCON seems to get confused if we change DCONLOAD too
- * frequently -- i.e., approximately faster than frame time.
+ * frequently -- i.e., approximately faster than frame time.
* normally we don't change it this fast, so in general we won't
* delay here.
*/
void dcon_load_holdoff(void)
{
struct timespec delta_t, now;
- while(1) {
+ while (1) {
getnstimeofday(&now);
delta_t = timespec_sub(now, dcon_load_time);
if (delta_t.tv_sec != 0 ||
printk("dcon_source_switch to CPU\n");
/* Enable the scanline interrupt bit */
if (dcon_write(DCON_REG_MODE, dcon_disp_mode | MODE_SCAN_INT))
- printk(KERN_ERR "olpc-dcon: couldn't enable scanline interrupt!\n");
+ printk(KERN_ERR
+ "olpc-dcon: couldn't enable scanline interrupt!\n");
else {
/* Wait up to one second for the scanline interrupt */
- wait_event_timeout(dcon_wait_queue, dcon_switched == 1, HZ);
+ wait_event_timeout(dcon_wait_queue,
+ dcon_switched == 1, HZ);
}
if (!dcon_switched)
int t;
struct timespec delta_t;
- printk("dcon_source_switch to DCON\n");
+ printk(KERN_INFO "dcon_source_switch to DCON\n");
add_wait_queue(&dcon_wait_queue, &wait);
set_current_state(TASK_UNINTERRUPTIBLE);
* the time between asserting DCONLOAD and the IRQ --
* if it's less than 20msec, then the DCON couldn't
* have seen two VSYNC pulses. in that case we
- * deassert and reassert, and hope for the best.
+ * deassert and reassert, and hope for the best.
* see http://dev.laptop.org/ticket/9664
*/
delta_t = timespec_sub(dcon_irq_time, dcon_load_time);
flush_scheduled_work();
}
-static int dconbl_set(struct backlight_device *dev) {
+static int dconbl_set(struct backlight_device *dev)
+{
int level = dev->props.brightness;
return 0;
}
-static int dconbl_get(struct backlight_device *dev) {
+static int dconbl_get(struct backlight_device *dev)
+{
return dcon_get_backlight();
}
{
char *endp;
- unsigned int output = simple_strtoul(buf, &endp, 0);
+ unsigned int output = strict_strtoul(buf, &endp, 0);
int size = endp - buf;
if (*endp && isspace(*endp))
if (_strtoul(buf, count, &output))
return -EINVAL;
- printk("dcon_freeze_store: %d\n", output);
+ printk(KERN_INFO "dcon_freeze_store: %d\n", output);
switch (output) {
case 0:
case 1:
dcon_set_source_sync(DCON_SOURCE_DCON);
break;
- case 2: // normally unused
+ case 2: /* normally unused */
dcon_set_source(DCON_SOURCE_DCON);
break;
default:
};
-static int dcon_reboot_notify(struct notifier_block *nb, unsigned long foo, void *bar)
+static int dcon_reboot_notify(struct notifier_block *nb,
+ unsigned long foo, void *bar)
{
if (dcon_client == NULL)
return 0;
.priority = -1,
};
-static int unfreeze_on_panic(struct notifier_block *nb, unsigned long e, void *p)
+static int unfreeze_on_panic(struct notifier_block *nb,
+ unsigned long e, void *p)
{
pdata->set_dconload(1);
return NOTIFY_DONE;
* When the framebuffer sleeps due to external sources (e.g. user idle), power
* down the DCON as well. Power it back up when the fb comes back to life.
*/
-static int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data)
+static int fb_notifier_callback(struct notifier_block *self,
+ unsigned long event, void *data)
{
struct fb_event *evdata = data;
int *blank = (int *) evdata->data;
dcon_device = platform_device_alloc("dcon", -1);
if (dcon_device == NULL) {
- printk("dcon: Unable to create the DCON device\n");
+ printk(KERN_ERR "dcon: Unable to create the DCON device\n");
rc = -ENOMEM;
goto eirq;
}
/* Place holder...*/
i2c_set_clientdata(client, dcon_device);
+ rc = platform_device_add(dcon_device);
- if ((rc = platform_device_add(dcon_device))) {
- printk("dcon: Unable to add the DCON device\n");
+ if (rc) {
+ printk(KERN_ERR "dcon: Unable to add the DCON device\n");
goto edev;
}
- for(i = 0; i < ARRAY_SIZE(dcon_device_files); i++) {
+ for (i = 0; i < ARRAY_SIZE(dcon_device_files); i++) {
rc = device_create_file(&dcon_device->dev,
&dcon_device_files[i]);
if (rc) {
NULL, &dcon_bl_ops, NULL);
if (IS_ERR(dcon_bl_dev)) {
- printk("Could not register the backlight device for the DCON (%ld)\n", PTR_ERR(dcon_bl_dev));
+ printk(KERN_ERR "Cannot register the backlight device (%ld)\n",
+ PTR_ERR(dcon_bl_dev));
dcon_bl_dev = NULL;
- }
- else {
+ } else {
dcon_bl_dev->props.max_brightness = 15;
dcon_bl_dev->props.power = FB_BLANK_UNBLANK;
dcon_bl_dev->props.brightness = dcon_get_backlight();