Commit d2b9a8a9 authored by David Brownell's avatar David Brownell Committed by Tony Lindgren

V4L: omap camera builds again

Fix some bitrot, including basic build/load functionality:

  - ov9640 code had syntax errors (!) and referenced missing fields
  - camera core included all kinds of crap, but not the v4l2 stuff
  - both omap16xx and 17xx used the wrong base clock
  - 16xx oopsed because its base clock did not exist
  - misuse of machine_is_omap_h3() in place of cpu_is_omap1710()
  - several exported symbols were goofed up
  - used bad call to reserve mem region
  - didn't destroy platform device correctly
  - ov9640 needed MODULE_LICENSE("GPL")

It's probably best to think of this as just making the camera code
build again, load/unload as modules, stop oopsing on 16xx, and be
a smidgeon cleaner ... since my (early/prototype) Mistral board won't
actually get to UBoot when a camera is connected.  :(
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 0b6b5f29
......@@ -20,40 +20,24 @@
* History:
* 27/03/05 Vladimir Barinov - Added support for power management
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/proc_fs.h>
#include <linux/ctype.h>
#include <linux/pagemap.h>
#include <linux/mm.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/videodev.h>
#include <linux/pci.h>
#include <linux/version.h>
#include <asm/semaphore.h>
#include <asm/processor.h>
#include <linux/dma-mapping.h>
#include <linux/fb.h>
#include <media/v4l2-common.h>
#include <asm/io.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
#include "sensor_if.h"
#include "camera_hw_if.h"
#include "camera_core.h"
struct camera_device *camera_dev;
extern struct omap_camera_sensor camera_sensor_if;
extern struct camera_hardware camera_hardware_if;
static struct camera_device *camera_dev;
static void camera_core_sgdma_process(struct camera_device *cam);
/* module parameters */
......@@ -1165,39 +1149,38 @@ static struct platform_driver camera_core_driver = {
#endif
};
static struct platform_device camera_core_device = {
.name = CAM_NAME,
.dev = {
.release = NULL,
},
.id = 0,
};
/* FIXME register omap16xx or omap24xx camera device in arch/arm/...
* system init code, with its resources and mux setup, NOT here.
* Then MODULE_ALIAS(CAM_NAME) so it hotplugs and coldplugs; this
* "legacy" driver style is trouble.
*/
static struct platform_device *cam;
void __exit
static void __exit
camera_core_cleanup(void)
{
platform_driver_unregister(&camera_core_driver);
platform_device_unregister(&camera_core_device);
return;
platform_device_unregister(cam);
}
static char banner[] __initdata = KERN_INFO "OMAP Camera driver initialzing\n";
int __init
static int __init
camera_core_init(void)
{
printk(banner);
platform_device_register(&camera_core_device);
platform_driver_register(&camera_core_driver);
cam = platform_device_register_simple(CAM_NAME, -1, NULL, 0);
return 0;
}
MODULE_AUTHOR("Texas Instruments.");
MODULE_DESCRIPTION("OMAP Video for Linux camera driver");
MODULE_LICENSE("GPL");
module_param(video_nr, int, 0);
MODULE_PARM_DESC(video_nr,
"Minor number for video device (-1 ==> auto assign)");
......
......@@ -151,6 +151,6 @@ struct camera_fh {
struct videobuf_queue vbq;
};
#define CAM_NAME "omap-camera"
#define CAM_NAME "omap_camera"
#endif /* CAMERA_CORE__H */
......@@ -45,4 +45,6 @@ struct camera_hardware {
int (*finish_dma)(void *);
};
extern struct camera_hardware camera_hardware_if;
#endif /* OMAP_CAMERA_HW_IF_H */
......@@ -39,6 +39,7 @@
#include "camera_hw_if.h"
#include "camera_core.h"
#define CONF_CAMERAIF_RESET_R 5
#define EN_PER 0
......@@ -70,6 +71,8 @@ struct omap16xxcam {
/* frequncy (in Hz) of camera interface functional clock (ocp_clk) */
unsigned long ocp_clk;
struct clk *func_clk;
/* dma related stuff */
spinlock_t dma_lock;
int free_dmach;
......@@ -127,12 +130,7 @@ omap16xx_cam_init(void)
omap_writew(omap_readw(ARM_RSTCT2) | (1 << EN_PER), ARM_RSTCT2);
/* enable peripheral clock */
if (machine_is_omap_h3())
clk_enable(clk_get(0, "tc2_ck"));
else {
clk_enable(clk_get(0, "armper_ck"));
clk_enable(clk_get(0, "armxor_ck"));
}
clk_enable(hardware_data.func_clk);
}
static void
......@@ -322,7 +320,7 @@ omap16xxcam_start_dma(struct sgdma_state *sgdma,
data->camdma[count].arg1 = arg1;
data->camdma[count].arg2 = arg2;
if (machine_is_omap_h3())
if (cpu_is_omap1710())
omap_set_dma_src_params(dmach, OMAP_DMA_PORT_OCP_T1,
OMAP_DMA_AMODE_CONSTANT, CAM_CAMDATA_REG,
0, 0);
......@@ -507,19 +505,25 @@ omap16xxcam_cleanup(void *priv)
{
struct omap16xxcam *data = (struct omap16xxcam *) priv;
if (!data->camera_regs)
return -EINVAL;
omap16xxcam_disable(data);
if (machine_is_omap_h3()) {
if (data->camera_regs) {
if (cpu_is_omap1710())
iounmap((void *)data->camera_regs);
data->camera_regs= NULL;
}
}
if (data->iobase_phys) {
release_mem_region(data->iobase_phys, CAMERA_IOSIZE);
data->iobase_phys = 0;
}
if (hardware_data.func_clk) {
clk_disable(hardware_data.func_clk);
clk_put(hardware_data.func_clk);
hardware_data.func_clk = NULL;
}
return 0;
}
......@@ -529,13 +533,15 @@ omap16xxcam_init(void)
{
unsigned long cam_iobase;
if (!request_region(CAMERA_BASE, CAMERA_IOSIZE, "OAMP16xx Camera")) {
printk ("OMAP16XX Parallel Camera Interface is already in use\n");
if (!request_mem_region(CAMERA_BASE, CAMERA_IOSIZE,
camera_hardware_if.name)) {
pr_debug("%s is already in use\n", camera_hardware_if.name);
return NULL;
}
if (machine_is_omap_h3()) {
cam_iobase = (unsigned long) ioremap (CAMERA_BASE, CAMERA_IOSIZE);
if (cpu_is_omap1710()) {
cam_iobase = (unsigned long) ioremap (CAMERA_BASE,
CAMERA_IOSIZE);
if (!cam_iobase) {
printk("CANNOT MAP CAMERA REGISTER\n");
return NULL;
......@@ -547,11 +553,13 @@ omap16xxcam_init(void)
/* Set the base address of the camera registers */
hardware_data.camera_regs = (camera_regs_t *)cam_iobase;
hardware_data.iobase_phys = (unsigned long) CAMERA_BASE;
/* get the input clock value to camera interface and store it */
if (machine_is_omap_h3())
hardware_data.ocp_clk = clk_get_rate(clk_get(0, "tc_ck"));
if (cpu_is_omap1710())
hardware_data.func_clk = clk_get(0, "tc2_ck");
else
hardware_data.ocp_clk = clk_get_rate(clk_get(0, "mpuper_ck"));
hardware_data.func_clk = clk_get(0, "armper_ck");
hardware_data.ocp_clk = clk_get_rate(hardware_data.func_clk);
/* Init the camera IF */
omap16xx_cam_init();
......@@ -566,7 +574,7 @@ omap16xxcam_init(void)
struct camera_hardware camera_hardware_if = {
.version = 0x01,
.name = "OMAP16xx Camera Parallel",
.name = "OMAP16xx Parallel Camera",
.init = omap16xxcam_init,
.cleanup = omap16xxcam_cleanup,
.open = omap16xxcam_open,
......
......@@ -45,4 +45,6 @@ struct omap_camera_sensor {
};
extern struct omap_camera_sensor camera_sensor_if;
#endif
......@@ -20,14 +20,13 @@
#include <media/video-buf.h>
#include <linux/delay.h>
#include <asm/mach-types.h>
#include <asm/arch/gpio.h>
#include "sensor_if.h"
#include "ov9640.h"
#include "h3sensorpower.h"
#include "h4sensorpower.h"
#define CAMERA_OV9640
#ifdef CAMERA_OV9640
struct ov9640_sensor {
/* I2C parameters */
......@@ -696,6 +695,11 @@ ov9640_powerup(void)
if (machine_is_omap_h2())
return 0;
#ifdef CONFIG_OMAP_OSK_MISTRAL
if (machine_is_omap_osk())
omap_set_gpio_dataout(11, 1);
#endif
if (machine_is_omap_h3()) {
err = h3_sensor_powerup();
if (err)
......@@ -718,6 +722,11 @@ ov9640_powerdown(void)
if (machine_is_omap_h2())
return 0;
#ifdef CONFIG_OMAP_OSK_MISTRAL
if (machine_is_omap_osk())
omap_set_gpio_dataout(11, 0);
#endif
if (machine_is_omap_h3()) {
err = h3_sensor_powerdown();
if (err)
......@@ -806,6 +815,7 @@ ov9640_i2c_attach_client(struct i2c_adapter *adap, int addr, int probe)
client->addr = addr;
client->driver = &ov9640sensor_i2c_driver;
client->adapter = adap;
strcpy(client->name, ov9640sensor_i2c_driver.driver.name);
err = i2c_attach_client(client);
if (err) {
......@@ -1125,7 +1135,7 @@ ov9640sensor_cleanup(void *priv)
static struct i2c_driver ov9640sensor_i2c_driver = {
.driver {
.driver = {
.name = "ov9640",
},
.id = I2C_DRIVERID_MISC, /*FIXME:accroding to i2c-ids.h */
......@@ -1180,10 +1190,6 @@ ov9640sensor_init(struct v4l2_pix_format *pix)
struct omap_camera_sensor camera_sensor_if = {
.version = 0x01,
.name = "OV9640",
.parallel_mode = PAR_MODE_NOBT8,
.hs_polarity = SYNC_ACTIVE_HIGH,
.vs_polarity = SYNC_ACTIVE_LOW,
.image_swap = 0,
.init = ov9640sensor_init,
.cleanup = ov9640sensor_cleanup,
.enum_pixformat = ov9640sensor_enum_pixformat,
......@@ -1196,7 +1202,11 @@ struct omap_camera_sensor camera_sensor_if = {
.power_on = ov9640sensor_power_on,
.power_off = ov9640sensor_power_off,
};
EXPORT_SYMBOL_GPL(camera_sensor_if);
MODULE_LICENSE("GPL");
#if 0
void print_ov9640_regs(void *priv)
{
struct ov9640_sensor *sensor = (struct ov9640_sensor *) priv;
......@@ -1207,5 +1217,4 @@ void print_ov9640_regs(void *priv)
else
printk("reg %x = %x\n", reg, val);
}
#endif /* ifdef CAMERA_OV9640 */
#endif
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