]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP2: Camera: Improve ov9640 code on board-h4.c
authorEduardo Valentin <eduardo.valentin@indt.org.br>
Wed, 21 Nov 2007 16:43:51 +0000 (12:43 -0400)
committerTony Lindgren <tony@atomide.com>
Fri, 23 Nov 2007 21:39:01 +0000 (13:39 -0800)
- Removes unnecessary structures and functions when config OV9640
is not selected.
- Reduces powerset code for ov9640.

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
Acked-by: Trilok Soni <soni.trilok@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/board-h4.c

index 85649bb157fa391e30aefb0f0b8d0fe85085a971..8fde8388cb46ce30ed0afe449ebcc4379b12c20e 100644 (file)
@@ -525,6 +525,7 @@ static void __init tusb_evm_setup(void)
 
 #endif
 
+#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE)
 /*
  * Common OV9640 register initialization for all image sizes, pixel formats,
  * and frame rates
@@ -563,63 +564,37 @@ const static struct ov9640_reg ov9640_common[] = {
        { OV9640_REG_TERM, OV9640_VAL_TERM }
 };
 
-#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE)
-static int ov9640_sensor_powerup(void)
+static int ov9640_sensor_power_set(int power)
 {
        unsigned char expa;
        int err;
 
        /* read current state of GPIO EXPA outputs */
        if ((err = read_gpio_expa(&expa, 0x20))) {
-               printk(KERN_ERR "Error reading GPIO EXPA\n");
-               return err;
-       }
-       /* Set GPIO EXPA P3 (CAMERA_MODULE_EN) to power-up sensor */
-       if ((err = write_gpio_expa(expa | 0x08, 0x20))) {
-               printk(KERN_ERR "Error writing to GPIO EXPA\n");
-               return err;
-       }
-
-       /* read current state of GPIO EXPA outputs */
-       if ((err = read_gpio_expa(&expa, 0x22))) {
-               printk(KERN_ERR "Error reading GPIO EXPA\n");
-               return err;
-       }
-       /* Clear GPIO EXPA P7 (CAM_RST) */
-       if ((err = write_gpio_expa(expa & ~0x80, 0x22))) {
-               printk(KERN_ERR "Error writing to GPIO EXPA\n");
+               printk(KERN_ERR "Error reading GPIO EXPA 0x20\n");
                return err;
        }
 
-       return 0;
-}
-static int ov9640_sensor_powerdown(void)
-{
-       unsigned char expa;
-       int err;
+       expa = power ? expa | 0x80 : expa & ~0x08;
 
-       /* read current state of GPIO EXPA outputs */
-       if ((err = read_gpio_expa(&expa, 0x20))) {
-               printk(KERN_ERR "Error reading GPIO EXPA\n");
-               return err;
-       }
-       /* Clear GPIO EXPA P3 (CAMERA_MODULE_EN) to power-down sensor */
-       if ((err = write_gpio_expa(expa & ~0x08, 0x20))) {
-               printk(KERN_ERR "Error writing to GPIO EXPA\n");
+       /* Set GPIO EXPA P3 (CAMERA_MODULE_EN) to power-up sensor */
+       if ((err = write_gpio_expa(expa, 0x20))) {
+               printk(KERN_ERR "Error writing to GPIO EXPA 0x20\n");
                return err;
        }
 
-       return 0;
-}
-
-static int ov9640_sensor_power_set(int power)
-{
-       int err = 0;
-
-       if (power)
-               err = ov9640_sensor_powerup();
-       else
-               err = ov9640_sensor_powerdown();
+       if (power) {
+               /* read current state of GPIO EXPA outputs */
+               if ((err = read_gpio_expa(&expa, 0x22))) {
+                       printk(KERN_ERR "Error reading GPIO EXPA\n");
+                       return err;
+               }
+               /* Clear GPIO EXPA P7 (CAM_RST) */
+               if ((err = write_gpio_expa(expa & ~0x80, 0x22))) {
+                       printk(KERN_ERR "Error writing to GPIO EXPA\n");
+                       return err;
+               }
+       }
 
        return err;
 }
@@ -643,16 +618,13 @@ static int ov9640_ifparm(struct v4l2_ifparm *p)
 
        return 0;
 }
-#else
-static int ov9640_sensor_power_set(int power) { return 0; }
-static int ov9640_ifparm(struct v4l2_ifparm *p) { return 0; }
-#endif
 
 static struct ov9640_platform_data h4_ov9640_platform_data = {
        .power_set      = ov9640_sensor_power_set,
        .default_regs   = ov9640_common,
        .ifparm         = ov9640_ifparm,
 };
+#endif
 
 static struct i2c_board_info __initdata h4_i2c_board_info[] = {
        {
@@ -664,10 +636,12 @@ static struct i2c_board_info __initdata h4_i2c_board_info[] = {
                I2C_BOARD_INFO("menelaus", 0x72),
                .irq = INT_24XX_SYS_NIRQ,
        },
+#if defined(CONFIG_VIDEO_OV9640) || defined(CONFIG_VIDEO_OV9640_MODULE)
        {
                I2C_BOARD_INFO("ov9640", 0x30),
                .platform_data = &h4_ov9640_platform_data,
        },
+#endif
 };
 
 static void __init omap_h4_init(void)