Skip to content

Commit

Permalink
[media] marvell-cam: Basic working MMP camera driver
Browse files Browse the repository at this point in the history
Now we have a camera working over the marvell cam controller core.  It
works like the cafe driver and has all the same limitations, contiguous DMA
only being one of them.  But it's a start.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Jonathan Corbet authored and Mauro Carvalho Chehab committed Jul 27, 2011
1 parent 595a93a commit 67a8dbb
Show file tree
Hide file tree
Showing 7 changed files with 386 additions and 9 deletions.
1 change: 1 addition & 0 deletions drivers/media/video/Makefile
Expand Up @@ -128,6 +128,7 @@ obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
obj-$(CONFIG_VIDEO_CX2341X) += cx2341x.o

obj-$(CONFIG_VIDEO_CAFE_CCIC) += marvell-ccic/
obj-$(CONFIG_VIDEO_MMP_CAMERA) += marvell-ccic/

obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o

Expand Down
11 changes: 11 additions & 0 deletions drivers/media/video/marvell-ccic/Kconfig
Expand Up @@ -7,3 +7,14 @@ config VIDEO_CAFE_CCIC
CMOS camera controller. This is the controller found on first-
generation OLPC systems.

config VIDEO_MMP_CAMERA
tristate "Marvell Armada 610 integrated camera controller support"
depends on ARCH_MMP && I2C && VIDEO_V4L2
select VIDEO_OV7670
select I2C_GPIO
---help---
This is a Video4Linux2 driver for the integrated camera
controller found on Marvell Armada 610 application
processors (and likely beyond). This is the controller found
in OLPC XO 1.75 systems.

4 changes: 4 additions & 0 deletions drivers/media/video/marvell-ccic/Makefile
@@ -1,2 +1,6 @@
obj-$(CONFIG_VIDEO_CAFE_CCIC) += cafe_ccic.o
cafe_ccic-y := cafe-driver.o mcam-core.o

obj-$(CONFIG_VIDEO_MMP_CAMERA) += mmp_camera.o
mmp_camera-y := mmp-driver.o mcam-core.o

28 changes: 20 additions & 8 deletions drivers/media/video/marvell-ccic/mcam-core.c
Expand Up @@ -167,7 +167,7 @@ static void mcam_set_config_needed(struct mcam_camera *cam, int needed)


/*
* Debugging and related. FIXME these are broken
* Debugging and related.
*/
#define cam_err(cam, fmt, arg...) \
dev_err((cam)->dev, fmt, ##arg);
Expand Down Expand Up @@ -202,7 +202,8 @@ static void mcam_ctlr_dma(struct mcam_camera *cam)
mcam_reg_clear_bit(cam, REG_CTRL1, C1_TWOBUFS);
} else
mcam_reg_set_bit(cam, REG_CTRL1, C1_TWOBUFS);
mcam_reg_write(cam, REG_UBAR, 0); /* 32 bits only for now */
if (cam->chip_id == V4L2_IDENT_CAFE)
mcam_reg_write(cam, REG_UBAR, 0); /* 32 bits only */
}

static void mcam_ctlr_image(struct mcam_camera *cam)
Expand Down Expand Up @@ -358,8 +359,8 @@ static void mcam_ctlr_power_up(struct mcam_camera *cam)
unsigned long flags;

spin_lock_irqsave(&cam->dev_lock, flags);
mcam_reg_clear_bit(cam, REG_CTRL1, C1_PWRDWN);
cam->plat_power_up(cam);
mcam_reg_clear_bit(cam, REG_CTRL1, C1_PWRDWN);
spin_unlock_irqrestore(&cam->dev_lock, flags);
msleep(5); /* Just to be sure */
}
Expand All @@ -369,8 +370,13 @@ static void mcam_ctlr_power_down(struct mcam_camera *cam)
unsigned long flags;

spin_lock_irqsave(&cam->dev_lock, flags);
cam->plat_power_down(cam);
/*
* School of hard knocks department: be sure we do any register
* twiddling on the controller *before* calling the platform
* power down routine.
*/
mcam_reg_set_bit(cam, REG_CTRL1, C1_PWRDWN);
cam->plat_power_down(cam);
spin_unlock_irqrestore(&cam->dev_lock, flags);
}

Expand Down Expand Up @@ -1622,14 +1628,20 @@ int mccic_register(struct mcam_camera *cam)

void mccic_shutdown(struct mcam_camera *cam)
{
if (cam->users > 0)
/*
* If we have no users (and we really, really should have no
* users) the device will already be powered down. Trying to
* take it down again will wedge the machine, which is frowned
* upon.
*/
if (cam->users > 0) {
cam_warn(cam, "Removing a device with users!\n");
mcam_ctlr_power_down(cam);
}
mcam_free_dma_bufs(cam);
if (cam->n_sbufs > 0)
/* What if they are still mapped? Shouldn't be, but... */
mcam_free_sio_buffers(cam);
mcam_ctlr_stop_dma(cam);
mcam_ctlr_power_down(cam);
mcam_free_dma_bufs(cam);
video_unregister_device(&cam->vdev);
v4l2_device_unregister(&cam->v4l2_dev);
}
Expand Down

0 comments on commit 67a8dbb

Please sign in to comment.