From: Komal Shah Date: Tue, 29 Nov 2005 01:55:32 +0000 (-0800) Subject: [PATCH] ARM: OMAP: camera: sensor cleanup X-Git-Tag: v2.6.15-omap2~74 X-Git-Url: http://www.pilppa.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f155971f98d64c9dbf99dfb49dc1df15f806deb6;p=linux-2.6-omap-h63xx.git [PATCH] ARM: OMAP: camera: sensor cleanup Attached patch for o sensor powerup/down cleanup o camera build infrastructure o kmalloc -> kzalloc --- diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 0c7f1e1c3e4..42084170148 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig @@ -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 diff --git a/drivers/media/video/omap/Makefile b/drivers/media/video/omap/Makefile index 1f6476a93be..c4c5a81b0d4 100644 --- a/drivers/media/video/omap/Makefile +++ b/drivers/media/video/omap/Makefile @@ -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)/.. diff --git a/drivers/media/video/omap/camera_core.c b/drivers/media/video/omap/camera_core.c index e9e84b11d16..12c1fd1735f 100644 --- a/drivers/media/video/omap/camera_core.c +++ b/drivers/media/video/omap/camera_core.c @@ -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 index 00000000000..ae76688ae2a --- /dev/null +++ b/drivers/media/video/omap/h3_sensor_power.c @@ -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 +#include + +#include + +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 index 00000000000..8587729cd71 --- /dev/null +++ b/drivers/media/video/omap/h3sensorpower.h @@ -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*/ diff --git a/drivers/media/video/omap/sensor_ov9640.c b/drivers/media/video/omap/sensor_ov9640.c index 9b4606fedbf..c7691d19356 100644 --- a/drivers/media/video/omap/sensor_ov9640.c +++ b/drivers/media/video/omap/sensor_ov9640.c @@ -20,10 +20,10 @@ #include #include #include -#include #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; }