Commit f155971f authored by Komal Shah's avatar Komal Shah Committed by Tony Lindgren

[PATCH] ARM: OMAP: camera: sensor cleanup

Attached patch for
o sensor powerup/down cleanup
o camera build infrastructure
o kmalloc -> kzalloc
parent aafe4298
......@@ -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
# 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)/..
......@@ -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;
......
/*
* 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);
/*
* 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*/
......@@ -20,10 +20,10 @@
#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,20 +669,14 @@ 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");
if (machine_is_omap_h3()) {
err = h3_sensor_powerup();
if (err)
return err;
}
......@@ -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");
if (machine_is_omap_h3()) {
err = h3_sensor_powerdown();
if (err)
return err;
}
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment