]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] ARM: OMAP: camera: sensor cleanup
authorKomal Shah <komal_shah802003@yahoo.com>
Tue, 29 Nov 2005 01:55:32 +0000 (17:55 -0800)
committerTony Lindgren <tony@atomide.com>
Tue, 29 Nov 2005 01:55:32 +0000 (17:55 -0800)
Attached patch for
o sensor powerup/down cleanup
o camera build infrastructure
o kmalloc -> kzalloc

drivers/media/video/Kconfig
drivers/media/video/omap/Makefile
drivers/media/video/omap/camera_core.c
drivers/media/video/omap/h3_sensor_power.c [new file with mode: 0644]
drivers/media/video/omap/h3sensorpower.h [new file with mode: 0644]
drivers/media/video/omap/sensor_ov9640.c

index 0c7f1e1c3e4ab554f8bc2cc90b6062d4ba0569e3..42084170148432cfadc71a48d1e4d7cb658c6bf0 100644 (file)
@@ -347,9 +347,6 @@ config VIDEO_DECODER
          Say Y here to compile drivers for SAA7115, SAA7127 and CX25840
          video  decoders.
 
-config VIDEO_OMAP_CAMERA
-       tristate "OMAP Video for Linux camera driver"
-       depends on VIDEO_DEV && ARCH_OMAP16XX
-       select VIDEO_BUF
+source drivers/media/video/omap/Kconfig
 
 endmenu
index 1f6476a93be13cdd8b9c603ca1647bded2203add..c4c5a81b0d41b71d93e5ea60046e0335dde63140 100644 (file)
@@ -1,7 +1,13 @@
-# Makefile for camera driver for H2/H3
+# Makefile for OMAP1/2 camera driver
 
-omapCamera-objs :=  camera_core.o omap16xxcam.o sensor_ov9640.o  
+obj-$(CONFIG_VIDEO_OMAP_CAMERA) += omapcamera.o
+obj-$(CONFIG_VIDEO_CAMERA_SENSOR_OV9640) += sensor_ov9640.o
 
-obj-y += omapCamera.o
+objs-yy := camera_core.o
+
+objs-y$(CONFIG_ARCH_OMAP16XX) += omap16xxcam.o
+objs-y$(CONFIG_MACH_OMAP_H3) += h3_sensor_power.o
+
+omapcamera-objs := $(objs-yy)
 
 EXTRA_CFLAGS = -I$(src)/..
index e9e84b11d167878e6353d6a4db7f58ae1080c711..12c1fd1735fd76b4b49e30a5cac254c9c24e966a 100644 (file)
@@ -1032,12 +1032,11 @@ camera_core_init(void)
        struct camera_device *cam;
        struct video_device *vfd;
 
-       cam = kmalloc(sizeof(struct camera_device), GFP_KERNEL);
+       cam = kzalloc(sizeof(struct camera_device), GFP_KERNEL);
        if (!cam) {
                printk(KERN_ERR CAM_NAME ": could not allocate memory\n");
                goto init_error;
        }
-       memset(cam, 0, sizeof(struct camera_device));
        
        /* Save the pointer to camera device in a global variable */
        camera_dev = cam;
diff --git a/drivers/media/video/omap/h3_sensor_power.c b/drivers/media/video/omap/h3_sensor_power.c
new file mode 100644 (file)
index 0000000..ae76688
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * drivers/media/video/omap/h3_sensor_power.c
+ *
+ * H3 sensor powerup/down functions.
+ *
+ * Author: Andy Lowe (source@mvista.com)
+ *
+ * Copyright (C) 2004 MontaVista Software, Inc.
+ * Copyright (C) 2004 Texas Instruments.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+
+#include <asm/arch/gpioexpander.h>
+
+int h3_sensor_powerup(void);
+int h3_sensor_powerdown(void);
+
+int
+h3_sensor_powerup(void)
+{
+       unsigned char expa;
+       int err;
+
+       /* read the current state of GPIO EXPA output */
+       if (( err = read_gpio_expa(&expa, 0x27))) {
+               printk(KERN_ERR "Error reading GPIO EXPA \n");
+               return err;
+       }
+       /* set GPIO EXPA P7 CAMERA_MOD_EN to power-up sensor */
+       if ((err = write_gpio_expa(expa | 0x80, 0x27))) {
+               printk(KERN_ERR "Error writing to GPIO EXPA \n");
+               return err;
+       }
+       return 0;
+}
+
+int
+h3_sensor_powerdown(void)
+{
+       unsigned char expa;
+       int err;
+
+       /* read the current state of GPIO EXPA output */
+       if (( err = read_gpio_expa(&expa, 0x27))) {
+               printk(KERN_ERR "Error reading GPIO EXPA \n");
+               return err;
+       }
+       /* clear GPIO EXPA P7 CAMERA_MOD_EN to power-up sensor */
+       if ((err = write_gpio_expa(expa & ~0x80, 0x27))) {
+               printk(KERN_ERR "Error writing to GPIO EXPA \n");
+               return err;
+       }
+       return 0;
+}
+
+EXPORT_SYMBOL(h3_sensor_powerup);
+EXPORT_SYMBOL(h3_sensor_powerdown);
diff --git a/drivers/media/video/omap/h3sensorpower.h b/drivers/media/video/omap/h3sensorpower.h
new file mode 100644 (file)
index 0000000..8587729
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * drivers/media/video/omap/h3sensorpower.h
+ *
+ * Copyright (C) 2005 Texas Instruments.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#ifndef H3SENSORPOWER_H
+#define H3SENSORPOWER_H
+
+int h3_sensor_powerup(void);
+int h3_sensor_powerdown(void);
+
+#endif /*H3SENSORPOWER_H*/
index 9b4606fedbfb4f0afa172f6ab6818a27f858f72f..c7691d19356f9c5d8cb724a924e8bdebaed7fc65 100644 (file)
 #include <media/video-buf.h>
 #include <linux/delay.h>
 #include <asm/mach-types.h>
-#include <asm/arch/gpioexpander.h>
 
 #include "sensor_if.h"
 #include "ov9640.h"
+#include "h3sensorpower.h"
 
 #define CAMERA_OV9640
 #ifdef CAMERA_OV9640
@@ -669,21 +669,15 @@ ov9640_configure(struct i2c_client *client,
 static int
 ov9640_powerup(void)
 {
-       unsigned char expa;
        int err;
 
        if (machine_is_omap_h2())
                return 0;
 
-       /* read the current state of GPIO EXPA output */
-       if (( err = read_gpio_expa(&expa, 0x27))){
-               printk(KERN_ERR "Error reading GPIO EXPA \n");
-               return err;
-       }
-       /* set GPIO EXPA P7 CAMERA_MOD_EN to power-up sensor */
-       if ((err = write_gpio_expa(expa | 0x80, 0x27))) {
-               printk(KERN_ERR "Error writing to GPIO EXPA \n");
-               return err;
+       if (machine_is_omap_h3()) {
+               err = h3_sensor_powerup();
+               if (err)
+                       return err;
        }
 
        return 0;
@@ -691,22 +685,17 @@ ov9640_powerup(void)
 static int
 ov9640_powerdown(void)
 {
-       unsigned char expa;
        int err;
 
        if (machine_is_omap_h2())
                return 0;
 
-       /* read the current state of GPIO EXPA output */
-       if (( err = read_gpio_expa(&expa, 0x27))){
-               printk(KERN_ERR "Error reading GPIO EXPA \n");
-               return err;
-       }
-       /* clear GPIO EXPA P7 CAMERA_MOD_EN to power-up sensor */
-       if ((err = write_gpio_expa(expa & ~0x80, 0x27))) {
-               printk(KERN_ERR "Error writing to GPIO EXPA \n");
-               return err;
+       if (machine_is_omap_h3()) {
+               err = h3_sensor_powerdown();
+               if (err)
+                       return err;
        }
+
        return 0;
 }