summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux/arch/arm/mach-pxa/devices.c32
-rw-r--r--linux/arch/arm/mach-pxa/pcm990-baseboard.c86
-rw-r--r--linux/drivers/media/video/mt9m001.c101
-rw-r--r--linux/drivers/media/video/mt9v022.c155
-rw-r--r--linux/drivers/media/video/pxa_camera.c317
-rw-r--r--linux/drivers/media/video/soc_camera.c144
-rw-r--r--linux/include/asm-arm/arch-pxa/pxa-regs.h80
-rw-r--r--linux/include/media/soc_camera.h72
8 files changed, 310 insertions, 677 deletions
diff --git a/linux/arch/arm/mach-pxa/devices.c b/linux/arch/arm/mach-pxa/devices.c
index 3838aabdf..bfccb80ac 100644
--- a/linux/arch/arm/mach-pxa/devices.c
+++ b/linux/arch/arm/mach-pxa/devices.c
@@ -11,7 +11,6 @@
#include <asm/arch/irda.h>
#include <asm/arch/i2c.h>
#include <asm/arch/ohci.h>
-#include <asm/arch/camera.h>
#include "devices.h"
@@ -541,37 +540,6 @@ struct platform_device pxa27x_device_ssp3 = {
.resource = pxa27x_resource_ssp3,
.num_resources = ARRAY_SIZE(pxa27x_resource_ssp3),
};
-
-static struct resource pxa27x_resource_camera[] = {
- [0] = {
- .start = 0x50000000,
- .end = 0x50000fff,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = IRQ_CAMERA,
- .end = IRQ_CAMERA,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static u64 pxa27x_dma_mask_camera = DMA_BIT_MASK(32);
-
-static struct platform_device pxa27x_device_camera = {
- .name = "pxa27x-camera",
- .id = 0, /* This is used to put cameras on this interface */
- .dev = {
- .dma_mask = &pxa27x_dma_mask_camera,
- .coherent_dma_mask = 0xffffffff,
- },
- .num_resources = ARRAY_SIZE(pxa27x_resource_camera),
- .resource = pxa27x_resource_camera,
-};
-
-void __init pxa_set_camera_info(struct pxacamera_platform_data *info)
-{
- pxa_register_device(&pxa27x_device_camera, info);
-}
#endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
#ifdef CONFIG_PXA3xx
diff --git a/linux/arch/arm/mach-pxa/pcm990-baseboard.c b/linux/arch/arm/mach-pxa/pcm990-baseboard.c
index 07ac050f2..3dda16a20 100644
--- a/linux/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/linux/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -23,13 +23,6 @@
#include <linux/irq.h>
#include <linux/platform_device.h>
#include <linux/ide.h>
-#include <linux/i2c.h>
-
-#include <media/soc_camera.h>
-
-#include <asm/gpio.h>
-#include <asm/arch/i2c.h>
-#include <asm/arch/camera.h>
#include <asm/mach/map.h>
#include <asm/arch/pxa-regs.h>
#include <asm/arch/mmc.h>
@@ -265,76 +258,6 @@ static struct pxaohci_platform_data pcm990_ohci_platform_data = {
};
/*
- * PXA27x Camera specific stuff
- */
-#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
-static int pcm990_pxacamera_init(struct device *dev)
-{
- pxa_gpio_mode(GPIO98_CIF_DD0_MD);
- pxa_gpio_mode(GPIO105_CIF_DD1_MD);
- pxa_gpio_mode(GPIO104_CIF_DD2_MD);
- pxa_gpio_mode(GPIO103_CIF_DD3_MD);
- pxa_gpio_mode(GPIO95_CIF_DD4_MD);
- pxa_gpio_mode(GPIO94_CIF_DD5_MD);
- pxa_gpio_mode(GPIO93_CIF_DD6_MD);
- pxa_gpio_mode(GPIO108_CIF_DD7_MD);
- pxa_gpio_mode(GPIO107_CIF_DD8_MD);
- pxa_gpio_mode(GPIO106_CIF_DD9_MD);
- pxa_gpio_mode(GPIO42_CIF_MCLK_MD);
- pxa_gpio_mode(GPIO45_CIF_PCLK_MD);
- pxa_gpio_mode(GPIO43_CIF_FV_MD);
- pxa_gpio_mode(GPIO44_CIF_LV_MD);
-
- return 0;
-}
-
-/*
- * CICR4: PCLK_EN: Pixel clock is supplied by the sensor
- * MCLK_EN: Master clock is generated by PXA
- * PCP: Data sampled on the falling edge of pixel clock
- */
-struct pxacamera_platform_data pcm990_pxacamera_platform_data = {
- .init = pcm990_pxacamera_init,
- .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_10 |
- PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN/* | PXA_CAMERA_PCP*/,
- .mclk_10khz = 1000,
-};
-
-#include <linux/i2c/pca953x.h>
-
-static struct pca953x_platform_data pca9536_data = {
- .gpio_base = NR_BUILTIN_GPIO + 1,
-};
-
-static struct soc_camera_link iclink[] = {
- {
- .bus_id = 0, /* Must match with the camera ID above */
- .gpio = NR_BUILTIN_GPIO + 1,
- }, {
- .bus_id = 0, /* Must match with the camera ID above */
- }
-};
-
-/* Board I2C devices. */
-static struct i2c_board_info __initdata pcm990_i2c_devices[] = {
- {
- /* Must initialize before the camera(s) */
- I2C_BOARD_INFO("pca953x", 0x41),
- .type = "pca9536",
- .platform_data = &pca9536_data,
- }, {
- I2C_BOARD_INFO("mt9v022", 0x48),
- .type = "mt9v022",
- .platform_data = &iclink[0], /* With extender */
- }, {
- I2C_BOARD_INFO("mt9m001", 0x5d),
- .type = "mt9m001",
- .platform_data = &iclink[0], /* With extender */
- },
-};
-#endif /* CONFIG_VIDEO_PXA27x ||CONFIG_VIDEO_PXA27x_MODULE */
-
-/*
* AC97 support
* Note: The connected AC97 mixer also reports interrupts at PCM990_AC97_IRQ
*/
@@ -403,14 +326,5 @@ void __init pcm990_baseboard_init(void)
/* USB host */
pxa_set_ohci_info(&pcm990_ohci_platform_data);
- pxa_set_i2c_info(NULL);
-
-#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
- pxa_set_camera_info(&pcm990_pxacamera_platform_data);
-
- i2c_register_board_info(0, pcm990_i2c_devices,
- ARRAY_SIZE(pcm990_i2c_devices));
-#endif
-
printk(KERN_INFO"PCM-990 Evaluation baseboard initialized\n");
}
diff --git a/linux/drivers/media/video/mt9m001.c b/linux/drivers/media/video/mt9m001.c
index 3fb5f63df..879f61ac4 100644
--- a/linux/drivers/media/video/mt9m001.c
+++ b/linux/drivers/media/video/mt9m001.c
@@ -210,64 +210,40 @@ static int bus_switch_act(struct mt9m001 *mt9m001, int go8bit)
#endif
}
-static int bus_switch_possible(struct mt9m001 *mt9m001)
-{
-#ifdef CONFIG_MT9M001_PCA9536_SWITCH
- return gpio_is_valid(mt9m001->switch_gpio);
-#else
- return 0;
-#endif
-}
-
-static int mt9m001_set_bus_param(struct soc_camera_device *icd,
- unsigned long flags)
+static int mt9m001_set_capture_format(struct soc_camera_device *icd,
+ __u32 pixfmt, struct v4l2_rect *rect, unsigned int flags)
{
struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
- unsigned int width_flag = flags & SOCAM_DATAWIDTH_MASK;
+ unsigned int width_flag = flags & (IS_DATAWIDTH_10 | IS_DATAWIDTH_9 |
+ IS_DATAWIDTH_8);
int ret;
+ const u16 hblank = 9, vblank = 25;
- /* Flags validity verified in test_bus_param */
+ /* MT9M001 has all capture_format parameters fixed */
+ if (!(flags & IS_MASTER) ||
+ !(flags & IS_PCLK_SAMPLE_RISING) ||
+ !(flags & IS_HSYNC_ACTIVE_HIGH) ||
+ !(flags & IS_VSYNC_ACTIVE_HIGH))
+ return -EINVAL;
+
+ /* Only one width bit may be set */
+ if (!is_power_of_2(width_flag))
+ return -EINVAL;
- if ((mt9m001->datawidth != 10 && (width_flag == SOCAM_DATAWIDTH_10)) ||
- (mt9m001->datawidth != 9 && (width_flag == SOCAM_DATAWIDTH_9)) ||
- (mt9m001->datawidth != 8 && (width_flag == SOCAM_DATAWIDTH_8))) {
+ if ((mt9m001->datawidth != 10 && (width_flag == IS_DATAWIDTH_10)) ||
+ (mt9m001->datawidth != 9 && (width_flag == IS_DATAWIDTH_9)) ||
+ (mt9m001->datawidth != 8 && (width_flag == IS_DATAWIDTH_8))) {
/* Well, we actually only can do 10 or 8 bits... */
- if (width_flag == SOCAM_DATAWIDTH_9)
+ if (width_flag == IS_DATAWIDTH_9)
return -EINVAL;
ret = bus_switch_act(mt9m001,
- width_flag == SOCAM_DATAWIDTH_8);
+ width_flag == IS_DATAWIDTH_8);
if (ret < 0)
return ret;
- mt9m001->datawidth = width_flag == SOCAM_DATAWIDTH_8 ? 8 : 10;
+ mt9m001->datawidth = width_flag == IS_DATAWIDTH_8 ? 8 : 10;
}
- return 0;
-}
-
-static unsigned long mt9m001_query_bus_param(struct soc_camera_device *icd)
-{
- struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
- unsigned int width_flag = SOCAM_DATAWIDTH_10;
-
- if (bus_switch_possible(mt9m001))
- width_flag |= SOCAM_DATAWIDTH_8;
-
- /* MT9M001 has all capture_format parameters fixed */
- return SOCAM_PCLK_SAMPLE_RISING |
- SOCAM_HSYNC_ACTIVE_HIGH |
- SOCAM_VSYNC_ACTIVE_HIGH |
- SOCAM_MASTER |
- width_flag;
-}
-
-static int mt9m001_set_fmt_cap(struct soc_camera_device *icd,
- __u32 pixfmt, struct v4l2_rect *rect)
-{
- struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
- int ret;
- const u16 hblank = 9, vblank = 25;
-
/* Blanking and start values - default... */
ret = reg_write(icd, MT9M001_HORIZONTAL_BLANKING, hblank);
if (ret >= 0)
@@ -372,6 +348,12 @@ static int mt9m001_set_register(struct soc_camera_device *icd,
}
#endif
+static unsigned int mt9m001_get_datawidth(struct soc_camera_device *icd)
+{
+ struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd);
+ return mt9m001->datawidth;
+}
+
const struct v4l2_queryctrl mt9m001_controls[] = {
{
.id = V4L2_CID_VFLIP,
@@ -410,23 +392,20 @@ const struct v4l2_queryctrl mt9m001_controls[] = {
}
};
-static int mt9m001_video_probe(struct soc_camera_device *);
-static void mt9m001_video_remove(struct soc_camera_device *);
-static int mt9m001_get_control(struct soc_camera_device *, struct v4l2_control *);
-static int mt9m001_set_control(struct soc_camera_device *, struct v4l2_control *);
+static int mt9m001_get_control(struct soc_camera_device *icd, struct v4l2_control *ctrl);
+static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_control *ctrl);
static struct soc_camera_ops mt9m001_ops = {
.owner = THIS_MODULE,
- .probe = mt9m001_video_probe,
- .remove = mt9m001_video_remove,
.init = mt9m001_init,
.release = mt9m001_release,
.start_capture = mt9m001_start_capture,
.stop_capture = mt9m001_stop_capture,
- .set_fmt_cap = mt9m001_set_fmt_cap,
+ .set_capture_format = mt9m001_set_capture_format,
.try_fmt_cap = mt9m001_try_fmt_cap,
- .set_bus_param = mt9m001_set_bus_param,
- .query_bus_param = mt9m001_query_bus_param,
+ .formats = NULL, /* Filled in later depending on the */
+ .num_formats = 0, /* camera type and data widths */
+ .get_datawidth = mt9m001_get_datawidth,
.controls = mt9m001_controls,
.num_controls = ARRAY_SIZE(mt9m001_controls),
.get_control = mt9m001_get_control,
@@ -575,19 +554,19 @@ static int mt9m001_video_probe(struct soc_camera_device *icd)
case 0x8411:
case 0x8421:
mt9m001->model = V4L2_IDENT_MT9M001C12ST;
- icd->formats = mt9m001_colour_formats;
+ mt9m001_ops.formats = mt9m001_colour_formats;
if (mt9m001->client->dev.platform_data)
- icd->num_formats = ARRAY_SIZE(mt9m001_colour_formats);
+ mt9m001_ops.num_formats = ARRAY_SIZE(mt9m001_colour_formats);
else
- icd->num_formats = 1;
+ mt9m001_ops.num_formats = 1;
break;
case 0x8431:
mt9m001->model = V4L2_IDENT_MT9M001C12STM;
- icd->formats = mt9m001_monochrome_formats;
+ mt9m001_ops.formats = mt9m001_monochrome_formats;
if (mt9m001->client->dev.platform_data)
- icd->num_formats = ARRAY_SIZE(mt9m001_monochrome_formats);
+ mt9m001_ops.num_formats = ARRAY_SIZE(mt9m001_monochrome_formats);
else
- icd->num_formats = 1;
+ mt9m001_ops.num_formats = 1;
break;
default:
ret = -ENODEV;
@@ -648,6 +627,8 @@ static int mt9m001_probe(struct i2c_client *client)
/* Second stage probe - when a capture adapter is there */
icd = &mt9m001->icd;
+ icd->probe = mt9m001_video_probe;
+ icd->remove = mt9m001_video_remove;
icd->ops = &mt9m001_ops;
icd->control = &client->dev;
icd->x_min = 20;
diff --git a/linux/drivers/media/video/mt9v022.c b/linux/drivers/media/video/mt9v022.c
index d4b9e2744..d677344d2 100644
--- a/linux/drivers/media/video/mt9v022.c
+++ b/linux/drivers/media/video/mt9v022.c
@@ -241,89 +241,19 @@ static int bus_switch_act(struct mt9v022 *mt9v022, int go8bit)
#endif
}
-static int bus_switch_possible(struct mt9v022 *mt9v022)
-{
-#ifdef CONFIG_MT9V022_PCA9536_SWITCH
- return gpio_is_valid(mt9v022->switch_gpio);
-#else
- return 0;
-#endif
-}
-
-static int mt9v022_set_bus_param(struct soc_camera_device *icd,
- unsigned long flags)
+static int mt9v022_set_capture_format(struct soc_camera_device *icd,
+ __u32 pixfmt, struct v4l2_rect *rect, unsigned int flags)
{
struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
- unsigned int width_flag = flags & SOCAM_DATAWIDTH_MASK;
- int ret;
+ unsigned int width_flag = flags & (IS_DATAWIDTH_10 | IS_DATAWIDTH_9 |
+ IS_DATAWIDTH_8);
u16 pixclk = 0;
+ int ret;
/* Only one width bit may be set */
if (!is_power_of_2(width_flag))
return -EINVAL;
- if ((mt9v022->datawidth != 10 && (width_flag == SOCAM_DATAWIDTH_10)) ||
- (mt9v022->datawidth != 9 && (width_flag == SOCAM_DATAWIDTH_9)) ||
- (mt9v022->datawidth != 8 && (width_flag == SOCAM_DATAWIDTH_8))) {
- /* Well, we actually only can do 10 or 8 bits... */
- if (width_flag == SOCAM_DATAWIDTH_9)
- return -EINVAL;
-
- ret = bus_switch_act(mt9v022,
- width_flag == SOCAM_DATAWIDTH_8);
- if (ret < 0)
- return ret;
-
- mt9v022->datawidth = width_flag == SOCAM_DATAWIDTH_8 ? 8 : 10;
- }
-
- if (flags & SOCAM_PCLK_SAMPLE_RISING)
- pixclk |= 0x10;
-
- if (!(flags & SOCAM_HSYNC_ACTIVE_HIGH))
- pixclk |= 0x1;
-
- if (!(flags & SOCAM_VSYNC_ACTIVE_HIGH))
- pixclk |= 0x2;
-
- ret = reg_write(icd, MT9V022_PIXCLK_FV_LV, pixclk);
- if (ret < 0)
- return ret;
-
- if (!(flags & SOCAM_MASTER))
- mt9v022->chip_control &= ~0x8;
-
- ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
- if (ret < 0)
- return ret;
-
- dev_dbg(&icd->dev, "Calculated pixclk 0x%x, chip control 0x%x\n",
- pixclk, mt9v022->chip_control);
-
- return 0;
-}
-
-static unsigned long mt9v022_query_bus_param(struct soc_camera_device *icd)
-{
- struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
- unsigned int width_flag = SOCAM_DATAWIDTH_10;
-
- if (bus_switch_possible(mt9v022))
- width_flag |= SOCAM_DATAWIDTH_8;
-
- return SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING |
- SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW |
- SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW |
- SOCAM_MASTER | SOCAM_SLAVE |
- width_flag;
-}
-
-static int mt9v022_set_fmt_cap(struct soc_camera_device *icd,
- __u32 pixfmt, struct v4l2_rect *rect)
-{
- struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
- int ret;
-
/* The caller provides a supported format, as verified per call to
* icd->try_fmt_cap(), datawidth is from our supported format list */
switch (pixfmt) {
@@ -378,6 +308,44 @@ static int mt9v022_set_fmt_cap(struct soc_camera_device *icd,
dev_dbg(&icd->dev, "Frame %ux%u pixel\n", rect->width, rect->height);
+ if ((mt9v022->datawidth != 10 && (width_flag == IS_DATAWIDTH_10)) ||
+ (mt9v022->datawidth != 9 && (width_flag == IS_DATAWIDTH_9)) ||
+ (mt9v022->datawidth != 8 && (width_flag == IS_DATAWIDTH_8))) {
+ /* Well, we actually only can do 10 or 8 bits... */
+ if (width_flag == IS_DATAWIDTH_9)
+ return -EINVAL;
+
+ ret = bus_switch_act(mt9v022,
+ width_flag == IS_DATAWIDTH_8);
+ if (ret < 0)
+ return ret;
+
+ mt9v022->datawidth = width_flag == IS_DATAWIDTH_8 ? 8 : 10;
+ }
+
+ if (flags & IS_PCLK_SAMPLE_RISING)
+ pixclk |= 0x10;
+
+ if (!(flags & IS_HSYNC_ACTIVE_HIGH))
+ pixclk |= 0x1;
+
+ if (!(flags & IS_VSYNC_ACTIVE_HIGH))
+ pixclk |= 0x2;
+
+ ret = reg_write(icd, MT9V022_PIXCLK_FV_LV, pixclk);
+ if (ret < 0)
+ return ret;
+
+ if (!(flags & IS_MASTER))
+ mt9v022->chip_control &= ~0x8;
+
+ ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
+ if (ret < 0)
+ return ret;
+
+ dev_dbg(&icd->dev, "Calculated pixclk 0x%x, chip control 0x%x\n",
+ pixclk, mt9v022->chip_control);
+
return 0;
}
@@ -452,6 +420,12 @@ static int mt9v022_set_register(struct soc_camera_device *icd,
}
#endif
+static unsigned int mt9v022_get_datawidth(struct soc_camera_device *icd)
+{
+ struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd);
+ return mt9v022->datawidth;
+}
+
const struct v4l2_queryctrl mt9v022_controls[] = {
{
.id = V4L2_CID_VFLIP,
@@ -506,23 +480,22 @@ const struct v4l2_queryctrl mt9v022_controls[] = {
}
};
-static int mt9v022_video_probe(struct soc_camera_device *);
-static void mt9v022_video_remove(struct soc_camera_device *);
-static int mt9v022_get_control(struct soc_camera_device *, struct v4l2_control *);
-static int mt9v022_set_control(struct soc_camera_device *, struct v4l2_control *);
+static int mt9v022_get_control(struct soc_camera_device *icd,
+ struct v4l2_control *ctrl);
+static int mt9v022_set_control(struct soc_camera_device *icd,
+ struct v4l2_control *ctrl);
static struct soc_camera_ops mt9v022_ops = {
.owner = THIS_MODULE,
- .probe = mt9v022_video_probe,
- .remove = mt9v022_video_remove,
.init = mt9v022_init,
.release = mt9v022_release,
.start_capture = mt9v022_start_capture,
.stop_capture = mt9v022_stop_capture,
- .set_fmt_cap = mt9v022_set_fmt_cap,
+ .set_capture_format = mt9v022_set_capture_format,
.try_fmt_cap = mt9v022_try_fmt_cap,
- .set_bus_param = mt9v022_set_bus_param,
- .query_bus_param = mt9v022_query_bus_param,
+ .formats = NULL, /* Filled in later depending on the */
+ .num_formats = 0, /* sensor type and data widths */
+ .get_datawidth = mt9v022_get_datawidth,
.controls = mt9v022_controls,
.num_controls = ARRAY_SIZE(mt9v022_controls),
.get_control = mt9v022_get_control,
@@ -705,19 +678,19 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
!strcmp("color", sensor_type))) {
ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11);
mt9v022->model = V4L2_IDENT_MT9V022IX7ATC;
- icd->formats = mt9v022_colour_formats;
+ mt9v022_ops.formats = mt9v022_colour_formats;
if (mt9v022->client->dev.platform_data)
- icd->num_formats = ARRAY_SIZE(mt9v022_colour_formats);
+ mt9v022_ops.num_formats = ARRAY_SIZE(mt9v022_colour_formats);
else
- icd->num_formats = 1;
+ mt9v022_ops.num_formats = 1;
} else {
ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11);
mt9v022->model = V4L2_IDENT_MT9V022IX7ATM;
- icd->formats = mt9v022_monochrome_formats;
+ mt9v022_ops.formats = mt9v022_monochrome_formats;
if (mt9v022->client->dev.platform_data)
- icd->num_formats = ARRAY_SIZE(mt9v022_monochrome_formats);
+ mt9v022_ops.num_formats = ARRAY_SIZE(mt9v022_monochrome_formats);
else
- icd->num_formats = 1;
+ mt9v022_ops.num_formats = 1;
}
if (ret >= 0)
@@ -773,6 +746,8 @@ static int mt9v022_probe(struct i2c_client *client)
i2c_set_clientdata(client, mt9v022);
icd = &mt9v022->icd;
+ icd->probe = mt9v022_video_probe;
+ icd->remove = mt9v022_video_remove;
icd->ops = &mt9v022_ops;
icd->control = &client->dev;
icd->x_min = 1;
diff --git a/linux/drivers/media/video/pxa_camera.c b/linux/drivers/media/video/pxa_camera.c
index 936db67a5..023d18c62 100644
--- a/linux/drivers/media/video/pxa_camera.c
+++ b/linux/drivers/media/video/pxa_camera.c
@@ -10,9 +10,10 @@
* (at your option) any later version.
*/
+#include <asm/io.h>
+
#include <linux/init.h>
#include <linux/module.h>
-#include <linux/io.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/errno.h>
@@ -41,26 +42,6 @@
#define PXA_CAM_VERSION_CODE KERNEL_VERSION(0, 0, 5)
#define PXA_CAM_DRV_NAME "pxa27x-camera"
-#define CICR0_SIM_MP (0 << 24)
-#define CICR0_SIM_SP (1 << 24)
-#define CICR0_SIM_MS (2 << 24)
-#define CICR0_SIM_EP (3 << 24)
-#define CICR0_SIM_ES (4 << 24)
-
-#define CICR1_DW_VAL(x) ((x) & CICR1_DW) /* Data bus width */
-#define CICR1_PPL_VAL(x) (((x) << 15) & CICR1_PPL) /* Pixels per line */
-
-#define CICR2_BLW_VAL(x) (((x) << 24) & CICR2_BLW) /* Beginning-of-line pixel clock wait count */
-#define CICR2_ELW_VAL(x) (((x) << 16) & CICR2_ELW) /* End-of-line pixel clock wait count */
-#define CICR2_HSW_VAL(x) (((x) << 10) & CICR2_HSW) /* Horizontal sync pulse width */
-#define CICR2_BFPW_VAL(x) (((x) << 3) & CICR2_BFPW) /* Beginning-of-frame pixel clock wait count */
-#define CICR2_FSW_VAL(x) (((x) << 0) & CICR2_FSW) /* Frame stabilization wait count */
-
-#define CICR3_BFW_VAL(x) (((x) << 24) & CICR3_BFW) /* Beginning-of-frame line clock wait count */
-#define CICR3_EFW_VAL(x) (((x) << 16) & CICR3_EFW) /* End-of-frame line clock wait count */
-#define CICR3_VSW_VAL(x) (((x) << 11) & CICR3_VSW) /* Vertical sync pulse width */
-#define CICR3_LPF_VAL(x) (((x) << 0) & CICR3_LPF) /* Lines per frame */
-
#define CICR0_IRQ_MASK (CICR0_TOM | CICR0_RDAVM | CICR0_FEM | CICR0_EOLM | \
CICR0_PERRM | CICR0_QDM | CICR0_CDM | CICR0_SOFM | \
CICR0_EOFM | CICR0_FOM)
@@ -102,6 +83,8 @@ struct pxa_camera_dev {
void __iomem *base;
unsigned int dma_chan_y;
+ enum v4l2_buf_type type;
+
struct pxacamera_platform_data *pdata;
struct resource *res;
unsigned long platform_flags;
@@ -111,6 +94,8 @@ struct pxa_camera_dev {
spinlock_t lock;
+ int dma_running;
+
struct pxa_buffer *active;
};
@@ -121,8 +106,9 @@ static unsigned int vid_limit = 16; /* Video memory limit, in Mb */
/*
* Videobuf operations
*/
-static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
- unsigned int *size)
+static int
+pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
+ unsigned int *size)
{
struct soc_camera_device *icd = vq->priv_data;
@@ -165,8 +151,9 @@ static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
buf->vb.state = VIDEOBUF_NEEDS_INIT;
}
-static int pxa_videobuf_prepare(struct videobuf_queue *vq,
- struct videobuf_buffer *vb, enum v4l2_field field)
+static int
+pxa_videobuf_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
+ enum v4l2_field field)
{
struct soc_camera_device *icd = vq->priv_data;
struct soc_camera_host *ici =
@@ -268,15 +255,15 @@ out:
return ret;
}
-static void pxa_videobuf_queue(struct videobuf_queue *vq,
- struct videobuf_buffer *vb)
+static void
+pxa_videobuf_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
{
struct soc_camera_device *icd = vq->priv_data;
struct soc_camera_host *ici =
to_soc_camera_host(icd->dev.parent);
struct pxa_camera_dev *pcdev = ici->priv;
struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb);
- struct pxa_buffer *active;
+ struct pxa_buffer *active = pcdev->active;
struct videobuf_dmabuf *dma = videobuf_to_dma(vb);
int nents = dma->sglen;
unsigned long flags;
@@ -288,9 +275,8 @@ static void pxa_videobuf_queue(struct videobuf_queue *vq,
list_add_tail(&vb->queue, &pcdev->capture);
vb->state = VIDEOBUF_ACTIVE;
- active = pcdev->active;
- if (!active) {
+ if (!pcdev->active) {
CIFR |= CIFR_RESET_F;
DDADR(pcdev->dma_chan_y) = buf->sg_dma;
DCSR(pcdev->dma_chan_y) = DCSR_RUN;
@@ -387,21 +373,22 @@ static void pxa_camera_dma_irq_y(int channel, void *data)
spin_lock_irqsave(&pcdev->lock, flags);
status = DCSR(pcdev->dma_chan_y);
- DCSR(pcdev->dma_chan_y) = status;
-
if (status & DCSR_BUSERR) {
- dev_err(pcdev->dev, "DMA Bus Error IRQ!\n");
+ dev_err(pcdev->dev, "%s: Bus Error\n", __FUNCTION__);
+ DCSR(pcdev->dma_chan_y) |= DCSR_BUSERR;
goto out;
}
if (!(status & DCSR_ENDINTR)) {
- dev_err(pcdev->dev, "Unknown DMA IRQ source, "
- "status: 0x%08x\n", status);
+ dev_err(pcdev->dev, "%s: unknown dma interrupt source. "
+ "status: 0x%08x\n", __FUNCTION__, status);
goto out;
}
+ DCSR(pcdev->dma_chan_y) |= DCSR_ENDINTR;
+
if (!pcdev->active) {
- dev_err(pcdev->dev, "DMA End IRQ with no active buffer!\n");
+ dev_err(pcdev->dev, "%s: no active buf\n", __FUNCTION__);
goto out;
}
@@ -411,7 +398,7 @@ static void pxa_camera_dma_irq_y(int channel, void *data)
dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
vb, vb->baddr, vb->bsize);
- /* _init is used to debug races, see comment in pxa_camera_reqbufs() */
+ /* _init is used to debug races, see comment in pxa_is_reqbufs() */
list_del_init(&vb->queue);
vb->state = VIDEOBUF_DONE;
do_gettimeofday(&vb->ts);
@@ -432,7 +419,7 @@ out:
spin_unlock_irqrestore(&pcdev->lock, flags);
}
-static struct videobuf_queue_ops pxa_videobuf_ops = {
+static struct videobuf_queue_ops pxa_video_ops = {
.buf_setup = pxa_videobuf_setup,
.buf_prepare = pxa_videobuf_prepare,
.buf_queue = pxa_videobuf_queue,
@@ -457,7 +444,7 @@ static int mclk_get_divisor(struct pxa_camera_dev *pcdev)
return div;
}
-static void pxa_camera_activate(struct pxa_camera_dev *pcdev)
+static void pxa_is_activate(struct pxa_camera_dev *pcdev)
{
struct pxacamera_platform_data *pdata = pcdev->pdata;
u32 cicr4 = 0;
@@ -499,7 +486,7 @@ static void pxa_camera_activate(struct pxa_camera_dev *pcdev)
clk_enable(pcdev->clk);
}
-static void pxa_camera_deactivate(struct pxa_camera_dev *pcdev)
+static void pxa_is_deactivate(struct pxa_camera_dev *pcdev)
{
struct pxacamera_platform_data *board = pcdev->pdata;
@@ -531,7 +518,7 @@ static irqreturn_t pxa_camera_irq(int irq, void *data)
/* The following two functions absolutely depend on the fact, that
* there can be only one camera on PXA quick capture interface */
-static int pxa_camera_add_device(struct soc_camera_device *icd)
+static int pxa_is_add_device(struct soc_camera_device *icd)
{
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct pxa_camera_dev *pcdev = ici->priv;
@@ -547,7 +534,7 @@ static int pxa_camera_add_device(struct soc_camera_device *icd)
dev_info(&icd->dev, "PXA Camera driver attached to camera %d\n",
icd->devnum);
- pxa_camera_activate(pcdev);
+ pxa_is_activate(pcdev);
ret = icd->ops->init(icd);
if (!ret)
@@ -559,7 +546,7 @@ ebusy:
return ret;
}
-static void pxa_camera_remove_device(struct soc_camera_device *icd)
+static void pxa_is_remove_device(struct soc_camera_device *icd)
{
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct pxa_camera_dev *pcdev = ici->priv;
@@ -576,114 +563,69 @@ static void pxa_camera_remove_device(struct soc_camera_device *icd)
icd->ops->release(icd);
- pxa_camera_deactivate(pcdev);
+ pxa_is_deactivate(pcdev);
pcdev->icd = NULL;
}
-static int test_platform_param(struct pxa_camera_dev *pcdev,
- unsigned char buswidth, unsigned long *flags)
+static int pxa_is_set_capture_format(struct soc_camera_device *icd,
+ __u32 pixfmt, struct v4l2_rect *rect)
{
- /*
- * Platform specified synchronization and pixel clock polarities are
- * only a recommendation and are only used during probing. The PXA270
- * quick capture interface supports both.
- */
- *flags = (pcdev->platform_flags & PXA_CAMERA_MASTER ?
- SOCAM_MASTER : SOCAM_SLAVE) |
- SOCAM_HSYNC_ACTIVE_HIGH |
- SOCAM_HSYNC_ACTIVE_LOW |
- SOCAM_VSYNC_ACTIVE_HIGH |
- SOCAM_VSYNC_ACTIVE_LOW |
- SOCAM_PCLK_SAMPLE_RISING |
- SOCAM_PCLK_SAMPLE_FALLING;
+ struct soc_camera_host *ici =
+ to_soc_camera_host(icd->dev.parent);
+ struct pxa_camera_dev *pcdev = ici->priv;
+ unsigned int datawidth = 0, dw, bpp;
+ u32 cicr0, cicr4 = 0;
+ int ret;
/* If requested data width is supported by the platform, use it */
- switch (buswidth) {
+ switch (icd->cached_datawidth) {
case 10:
- if (!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_10))
- return -EINVAL;
- *flags |= SOCAM_DATAWIDTH_10;
+ if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_10)
+ datawidth = IS_DATAWIDTH_10;
break;
case 9:
- if (!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_9))
- return -EINVAL;
- *flags |= SOCAM_DATAWIDTH_9;
+ if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_9)
+ datawidth = IS_DATAWIDTH_9;
break;
case 8:
- if (!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8))
- return -EINVAL;
- *flags |= SOCAM_DATAWIDTH_8;
+ if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8)
+ datawidth = IS_DATAWIDTH_8;
}
-
- return 0;
-}
-
-static int pxa_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
-{
- struct soc_camera_host *ici =
- to_soc_camera_host(icd->dev.parent);
- struct pxa_camera_dev *pcdev = ici->priv;
- unsigned long dw, bpp, bus_flags, camera_flags, common_flags;
- u32 cicr0, cicr4 = 0;
- int ret = test_platform_param(pcdev, icd->buswidth, &bus_flags);
-
- if (ret < 0)
- return ret;
-
- camera_flags = icd->ops->query_bus_param(icd);
-
- common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags);
- if (!common_flags)
+ if (!datawidth)
return -EINVAL;
- /* Make choises, based on platform preferences */
- if ((common_flags & SOCAM_HSYNC_ACTIVE_HIGH) &&
- (common_flags & SOCAM_HSYNC_ACTIVE_LOW)) {
- if (pcdev->platform_flags & PXA_CAMERA_HSP)
- common_flags &= ~SOCAM_HSYNC_ACTIVE_HIGH;
- else
- common_flags &= ~SOCAM_HSYNC_ACTIVE_LOW;
- }
-
- if ((common_flags & SOCAM_VSYNC_ACTIVE_HIGH) &&
- (common_flags & SOCAM_VSYNC_ACTIVE_LOW)) {
- if (pcdev->platform_flags & PXA_CAMERA_VSP)
- common_flags &= ~SOCAM_VSYNC_ACTIVE_HIGH;
- else
- common_flags &= ~SOCAM_VSYNC_ACTIVE_LOW;
- }
-
- if ((common_flags & SOCAM_PCLK_SAMPLE_RISING) &&
- (common_flags & SOCAM_PCLK_SAMPLE_FALLING)) {
- if (pcdev->platform_flags & PXA_CAMERA_PCP)
- common_flags &= ~SOCAM_PCLK_SAMPLE_RISING;
- else
- common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING;
- }
-
- ret = icd->ops->set_bus_param(icd, common_flags);
+ ret = icd->ops->set_capture_format(icd, pixfmt, rect,
+ datawidth |
+ (pcdev->platform_flags & PXA_CAMERA_MASTER ?
+ IS_MASTER : 0) |
+ (pcdev->platform_flags & PXA_CAMERA_HSP ?
+ 0 : IS_HSYNC_ACTIVE_HIGH) |
+ (pcdev->platform_flags & PXA_CAMERA_VSP ?
+ 0 : IS_VSYNC_ACTIVE_HIGH) |
+ (pcdev->platform_flags & PXA_CAMERA_PCP ?
+ 0 : IS_PCLK_SAMPLE_RISING));
if (ret < 0)
return ret;
/* Datawidth is now guaranteed to be equal to one of the three values.
* We fix bit-per-pixel equal to data-width... */
- switch (common_flags & SOCAM_DATAWIDTH_MASK) {
- case SOCAM_DATAWIDTH_10:
- icd->buswidth = 10;
+ switch (datawidth) {
+ case IS_DATAWIDTH_10:
+ icd->cached_datawidth = 10;
dw = 4;
bpp = 0x40;
break;
- case SOCAM_DATAWIDTH_9:
- icd->buswidth = 9;
+ case IS_DATAWIDTH_9:
+ icd->cached_datawidth = 9;
dw = 3;
bpp = 0x20;
break;
default:
/* Actually it can only be 8 now,
* default is just to silence compiler warnings */
- case SOCAM_DATAWIDTH_8:
- icd->buswidth = 8;
+ case IS_DATAWIDTH_8:
+ icd->cached_datawidth = 8;
dw = 2;
bpp = 0;
}
@@ -692,54 +634,32 @@ static int pxa_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
cicr4 |= CICR4_PCLK_EN;
if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
cicr4 |= CICR4_MCLK_EN;
- if (common_flags & SOCAM_PCLK_SAMPLE_FALLING)
+ if (pcdev->platform_flags & PXA_CAMERA_PCP)
cicr4 |= CICR4_PCP;
- if (common_flags & SOCAM_HSYNC_ACTIVE_LOW)
+ if (pcdev->platform_flags & PXA_CAMERA_HSP)
cicr4 |= CICR4_HSP;
- if (common_flags & SOCAM_VSYNC_ACTIVE_LOW)
+ if (pcdev->platform_flags & PXA_CAMERA_VSP)
cicr4 |= CICR4_VSP;
cicr0 = CICR0;
if (cicr0 & CICR0_ENB)
CICR0 = cicr0 & ~CICR0_ENB;
- CICR1 = CICR1_PPL_VAL(icd->width - 1) | bpp | dw;
+ CICR1 = CICR1_PPL_VAL(rect->width - 1) | bpp | dw;
CICR2 = 0;
- CICR3 = CICR3_LPF_VAL(icd->height - 1) |
+ CICR3 = CICR3_LPF_VAL(rect->height - 1) |
CICR3_BFW_VAL(min((unsigned short)255, icd->y_skip_top));
CICR4 = mclk_get_divisor(pcdev) | cicr4;
/* CIF interrupts are not used, only DMA */
CICR0 = (pcdev->platform_flags & PXA_CAMERA_MASTER ?
- CICR0_SIM_MP : (CICR0_SL_CAP_EN | CICR0_SIM_SP)) |
+ 0 : (CICR0_SL_CAP_EN | CICR0_SIM_SP)) |
CICR0_DMAEN | CICR0_IRQ_MASK | (cicr0 & CICR0_ENB);
return 0;
}
-static int pxa_camera_try_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
-{
- struct soc_camera_host *ici =
- to_soc_camera_host(icd->dev.parent);
- struct pxa_camera_dev *pcdev = ici->priv;
- unsigned long bus_flags, camera_flags;
- int ret = test_platform_param(pcdev, icd->buswidth, &bus_flags);
-
- if (ret < 0)
- return ret;
-
- camera_flags = icd->ops->query_bus_param(icd);
-
- return soc_camera_bus_param_compatible(camera_flags, bus_flags) ? 0 : -EINVAL;
-}
-
-static int pxa_camera_set_fmt_cap(struct soc_camera_device *icd,
- __u32 pixfmt, struct v4l2_rect *rect)
-{
- return icd->ops->set_fmt_cap(icd, pixfmt, rect);
-}
-
-static int pxa_camera_try_fmt_cap(struct soc_camera_device *icd,
- struct v4l2_format *f)
+static int pxa_is_try_fmt_cap(struct soc_camera_host *ici,
+ struct v4l2_format *f)
{
/* limit to pxa hardware capabilities */
if (f->fmt.pix.height < 32)
@@ -752,12 +672,11 @@ static int pxa_camera_try_fmt_cap(struct soc_camera_device *icd,
f->fmt.pix.width = 2048;
f->fmt.pix.width &= ~0x01;
- /* limit to sensor capabilities */
- return icd->ops->try_fmt_cap(icd, f);
+ return 0;
}
-static int pxa_camera_reqbufs(struct soc_camera_file *icf,
- struct v4l2_requestbuffers *p)
+static int pxa_is_reqbufs(struct soc_camera_file *icf,
+ struct v4l2_requestbuffers *p)
{
int i;
@@ -775,7 +694,7 @@ static int pxa_camera_reqbufs(struct soc_camera_file *icf,
return 0;
}
-static unsigned int pxa_camera_poll(struct file *file, poll_table *pt)
+static unsigned int pxa_is_poll(struct file *file, poll_table *pt)
{
struct soc_camera_file *icf = file->private_data;
struct pxa_buffer *buf;
@@ -792,8 +711,8 @@ static unsigned int pxa_camera_poll(struct file *file, poll_table *pt)
return 0;
}
-static int pxa_camera_querycap(struct soc_camera_host *ici,
- struct v4l2_capability *cap)
+static int pxa_is_querycap(struct soc_camera_host *ici,
+ struct v4l2_capability *cap)
{
/* cap->name is set by the firendly caller:-> */
strlcpy(cap->card, pxa_cam_driver_description, sizeof(cap->card));
@@ -803,35 +722,18 @@ static int pxa_camera_querycap(struct soc_camera_host *ici,
return 0;
}
-static spinlock_t *pxa_camera_spinlock_alloc(struct soc_camera_file *icf)
-{
- struct soc_camera_host *ici =
- to_soc_camera_host(icf->icd->dev.parent);
- struct pxa_camera_dev *pcdev = ici->priv;
-
- return &pcdev->lock;
-}
-
-static struct soc_camera_host_ops pxa_soc_camera_host_ops = {
- .owner = THIS_MODULE,
- .add = pxa_camera_add_device,
- .remove = pxa_camera_remove_device,
- .set_fmt_cap = pxa_camera_set_fmt_cap,
- .try_fmt_cap = pxa_camera_try_fmt_cap,
- .reqbufs = pxa_camera_reqbufs,
- .poll = pxa_camera_poll,
- .querycap = pxa_camera_querycap,
- .try_bus_param = pxa_camera_try_bus_param,
- .set_bus_param = pxa_camera_set_bus_param,
- .spinlock_alloc = pxa_camera_spinlock_alloc,
-};
-
-/* Should be allocated dynamically too, but we have only one. */
+/* Should beallocated dynamically too, but we have only one. */
static struct soc_camera_host pxa_soc_camera_host = {
.drv_name = PXA_CAM_DRV_NAME,
- .vbq_ops = &pxa_videobuf_ops,
+ .vbq_ops = &pxa_video_ops,
+ .add = pxa_is_add_device,
+ .remove = pxa_is_remove_device,
.msize = sizeof(struct pxa_buffer),
- .ops = &pxa_soc_camera_host_ops,
+ .set_capture_format = pxa_is_set_capture_format,
+ .try_fmt_cap = pxa_is_try_fmt_cap,
+ .reqbufs = pxa_is_reqbufs,
+ .poll = pxa_is_poll,
+ .querycap = pxa_is_querycap,
};
static int pxa_camera_probe(struct platform_device *pdev)
@@ -851,7 +753,8 @@ static int pxa_camera_probe(struct platform_device *pdev)
pcdev = kzalloc(sizeof(*pcdev), GFP_KERNEL);
if (!pcdev) {
- dev_err(&pdev->dev, "Could not allocate pcdev\n");
+ dev_err(&pdev->dev, "%s: Could not allocate pcdev\n",
+ __FUNCTION__);
err = -ENOMEM;
goto exit;
}
@@ -867,8 +770,8 @@ static int pxa_camera_probe(struct platform_device *pdev)
pcdev->pdata = pdev->dev.platform_data;
pcdev->platform_flags = pcdev->pdata->flags;
- if (!(pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 |
- PXA_CAMERA_DATAWIDTH_9 | PXA_CAMERA_DATAWIDTH_10))) {
+ if (!pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 |
+ PXA_CAMERA_DATAWIDTH_9 | PXA_CAMERA_DATAWIDTH_10)) {
/* Platform hasn't set available data widths. This is bad.
* Warn and use a default. */
dev_warn(&pdev->dev, "WARNING! Platform hasn't set available "
@@ -927,7 +830,7 @@ static int pxa_camera_probe(struct platform_device *pdev)
pxa_soc_camera_host.priv = pcdev;
pxa_soc_camera_host.dev.parent = &pdev->dev;
pxa_soc_camera_host.nr = pdev->id;
- err = soc_camera_host_register(&pxa_soc_camera_host);
+ err = soc_camera_host_register(&pxa_soc_camera_host, THIS_MODULE);
if (err)
goto exit_free_irq;
@@ -968,17 +871,51 @@ static int __devexit pxa_camera_remove(struct platform_device *pdev)
kfree(pcdev);
- dev_info(&pdev->dev, "PXA Camera driver unloaded\n");
+ dev_info(&pdev->dev, "%s: PXA Camera driver unloaded\n", __FUNCTION__);
+
+ return 0;
+}
+
+/*
+ * Suspend the Camera Module.
+ */
+static int pxa_camera_suspend(struct platform_device *pdev, pm_message_t level)
+{
+ struct pxa_camera_dev *pcdev = platform_get_drvdata(pdev);
+
+ dev_info(&pdev->dev, "camera suspend\n");
+ disable_irq(pcdev->irq);
+ return 0;
+}
+
+/*
+ * Resume the Camera Module.
+ */
+static int pxa_camera_resume(struct platform_device *pdev)
+{
+ struct pxa_camera_dev *pcdev = platform_get_drvdata(pdev);
+
+ dev_info(&pdev->dev, "camera resume\n");
+ enable_irq(pcdev->irq);
+
+/* if (pcdev) { */ /* FIXME: dev in use? */
+/* DRCMR68 = pcdev->dma_chan_y | DRCMR_MAPVLD; */
+/* DRCMR69 = pcdev->dma_chan_cb | DRCMR_MAPVLD; */
+/* DRCMR70 = pcdev->dma_chan_cr | DRCMR_MAPVLD; */
+/* } */
return 0;
}
+
static struct platform_driver pxa_camera_driver = {
.driver = {
.name = PXA_CAM_DRV_NAME,
},
.probe = pxa_camera_probe,
.remove = __exit_p(pxa_camera_remove),
+ .suspend = pxa_camera_suspend,
+ .resume = pxa_camera_resume,
};
diff --git a/linux/drivers/media/video/soc_camera.c b/linux/drivers/media/video/soc_camera.c
index a1b92446c..124406683 100644
--- a/linux/drivers/media/video/soc_camera.c
+++ b/linux/drivers/media/video/soc_camera.c
@@ -38,9 +38,9 @@ format_by_fourcc(struct soc_camera_device *icd, unsigned int fourcc)
{
unsigned int i;
- for (i = 0; i < icd->num_formats; i++)
- if (icd->formats[i].fourcc == fourcc)
- return icd->formats + i;
+ for (i = 0; i < icd->ops->num_formats; i++)
+ if (icd->ops->formats[i].fourcc == fourcc)
+ return icd->ops->formats + i;
return NULL;
}
@@ -75,13 +75,12 @@ static int soc_camera_try_fmt_cap(struct file *file, void *priv,
return -EINVAL;
}
- /* test physical bus parameters */
- ret = ici->ops->try_bus_param(icd, f->fmt.pix.pixelformat);
- if (ret)
- return ret;
+ /* limit to host capabilities */
+ ret = ici->try_fmt_cap(ici, f);
- /* limit format to hardware capabilities */
- ret = ici->ops->try_fmt_cap(icd, f);
+ /* limit to sensor capabilities */
+ if (!ret)
+ ret = icd->ops->try_fmt_cap(icd, f);
/* calculate missing fields */
f->fmt.pix.field = field;
@@ -143,7 +142,9 @@ static int soc_camera_reqbufs(struct file *file, void *priv,
if (ret < 0)
return ret;
- return ici->ops->reqbufs(icf, p);
+ return ici->reqbufs(icf, p);
+
+ return ret;
}
static int soc_camera_querybuf(struct file *file, void *priv,
@@ -182,7 +183,6 @@ static int soc_camera_open(struct inode *inode, struct file *file)
struct soc_camera_device *icd;
struct soc_camera_host *ici;
struct soc_camera_file *icf;
- spinlock_t *lock;
int ret;
icf = vmalloc(sizeof(*icf));
@@ -202,25 +202,19 @@ static int soc_camera_open(struct inode *inode, struct file *file)
goto emgd;
}
- if (!try_module_get(ici->ops->owner)) {
+ if (!try_module_get(ici->owner)) {
dev_err(&icd->dev, "Couldn't lock capture bus driver.\n");
ret = -EINVAL;
goto emgi;
}
- icf->icd = icd;
-
- icf->lock = ici->ops->spinlock_alloc(icf);
- if (!icf->lock) {
- ret = -ENOMEM;
- goto esla;
- }
-
icd->use_count++;
+ icf->icd = icd;
+
/* Now we really have to activate the camera */
if (icd->use_count == 1) {
- ret = ici->ops->add(icd);
+ ret = ici->add(icd);
if (ret < 0) {
dev_err(&icd->dev, "Couldn't activate the camera: %d\n", ret);
icd->use_count--;
@@ -234,8 +228,8 @@ static int soc_camera_open(struct inode *inode, struct file *file)
dev_dbg(&icd->dev, "camera device open\n");
/* We must pass NULL as dev pointer, then all pci_* dma operations
- * transform to normal dma_* ones. */
- videobuf_queue_sg_init(&icf->vb_vidq, ici->vbq_ops, NULL, icf->lock,
+ * transform to normal dma_* ones. Do we need an irqlock? */
+ videobuf_queue_sg_init(&icf->vb_vidq, ici->vbq_ops, NULL, NULL,
V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE,
ici->msize, icd);
@@ -243,12 +237,7 @@ static int soc_camera_open(struct inode *inode, struct file *file)
/* All errors are entered with the video_lock held */
eiciadd:
- lock = icf->lock;
- icf->lock = NULL;
- if (ici->ops->spinlock_free)
- ici->ops->spinlock_free(lock);
-esla:
- module_put(ici->ops->owner);
+ module_put(ici->owner);
emgi:
module_put(icd->ops->owner);
emgd:
@@ -263,20 +252,16 @@ static int soc_camera_close(struct inode *inode, struct file *file)
struct soc_camera_device *icd = icf->icd;
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct video_device *vdev = icd->vdev;
- spinlock_t *lock = icf->lock;
mutex_lock(&video_lock);
icd->use_count--;
if (!icd->use_count)
- ici->ops->remove(icd);
- icf->lock = NULL;
- if (ici->ops->spinlock_free)
- ici->ops->spinlock_free(lock);
+ ici->remove(icd);
module_put(icd->ops->owner);
- module_put(ici->ops->owner);
+ module_put(ici->owner);
mutex_unlock(&video_lock);
- vfree(icf);
+ vfree(file->private_data);
dev_dbg(vdev->dev, "camera device close\n");
@@ -326,7 +311,7 @@ static unsigned int soc_camera_poll(struct file *file, poll_table *pt)
return POLLERR;
}
- return ici->ops->poll(file, pt);
+ return ici->poll(file, pt);
}
@@ -359,8 +344,8 @@ static int soc_camera_s_fmt_cap(struct file *file, void *priv,
if (!data_fmt)
return -EINVAL;
- /* buswidth may be further adjusted by the ici */
- icd->buswidth = data_fmt->depth;
+ /* cached_datawidth may be further adjusted by the ici */
+ icd->cached_datawidth = data_fmt->depth;
ret = soc_camera_try_fmt_cap(file, icf, f);
if (ret < 0)
@@ -370,23 +355,22 @@ static int soc_camera_s_fmt_cap(struct file *file, void *priv,
rect.top = icd->y_current;
rect.width = f->fmt.pix.width;
rect.height = f->fmt.pix.height;
- ret = ici->ops->set_fmt_cap(icd, f->fmt.pix.pixelformat, &rect);
- if (ret < 0)
- return ret;
-
- icd->current_fmt = data_fmt;
- icd->width = rect.width;
- icd->height = rect.height;
- icf->vb_vidq.field = f->fmt.pix.field;
- if (V4L2_BUF_TYPE_VIDEO_CAPTURE != f->type)
- dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n",
- f->type);
+ ret = ici->set_capture_format(icd, f->fmt.pix.pixelformat, &rect);
- dev_dbg(&icd->dev, "set width: %d height: %d\n",
- icd->width, icd->height);
+ if (!ret) {
+ icd->current_fmt = data_fmt;
+ icd->width = rect.width;
+ icd->height = rect.height;
+ icf->vb_vidq.field = f->fmt.pix.field;
+ if (V4L2_BUF_TYPE_VIDEO_CAPTURE != f->type)
+ dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n",
+ f->type);
+
+ dev_dbg(&icd->dev, "set width: %d height: %d\n",
+ icd->width, icd->height);
+ }
- /* set physical bus parameters */
- return ici->ops->set_bus_param(icd, f->fmt.pix.pixelformat);
+ return ret;
}
static int soc_camera_enum_fmt_cap(struct file *file, void *priv,
@@ -398,10 +382,10 @@ static int soc_camera_enum_fmt_cap(struct file *file, void *priv,
WARN_ON(priv != file->private_data);
- if (f->index >= icd->num_formats)
+ if (f->index >= icd->ops->num_formats)
return -EINVAL;
- format = &icd->formats[f->index];
+ format = &icd->ops->formats[f->index];
strlcpy(f->description, format->name, sizeof(f->description));
f->pixelformat = format->fourcc;
@@ -440,7 +424,7 @@ static int soc_camera_querycap(struct file *file, void *priv,
WARN_ON(priv != file->private_data);
strlcpy(cap->driver, ici->drv_name, sizeof(cap->driver));
- return ici->ops->querycap(ici, cap);
+ return ici->querycap(ici, cap);
}
static int soc_camera_streamon(struct file *file, void *priv,
@@ -593,7 +577,7 @@ static int soc_camera_s_crop(struct file *file, void *fh,
if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
- ret = ici->ops->set_fmt_cap(icd, 0, &a->c);
+ ret = ici->set_capture_format(icd, 0, &a->c);
if (!ret) {
icd->width = a->c.width;
icd->height = a->c.height;
@@ -715,16 +699,16 @@ static int soc_camera_probe(struct device *dev)
to_soc_camera_host(icd->dev.parent);
int ret;
- if (!icd->ops->probe)
+ if (!icd->probe)
return -ENODEV;
/* We only call ->add() here to activate and probe the camera.
* We shall ->remove() and deactivate it immediately afterwards. */
- ret = ici->ops->add(icd);
+ ret = ici->add(icd);
if (ret < 0)
return ret;
- ret = icd->ops->probe(icd);
+ ret = icd->probe(icd);
if (ret >= 0) {
const struct v4l2_queryctrl *qctrl;
@@ -734,7 +718,7 @@ static int soc_camera_probe(struct device *dev)
icd->exposure = qctrl ? qctrl->default_value :
(unsigned short)~0;
}
- ici->ops->remove(icd);
+ ici->remove(icd);
return ret;
}
@@ -745,8 +729,8 @@ static int soc_camera_remove(struct device *dev)
{
struct soc_camera_device *icd = to_soc_camera_dev(dev);
- if (icd->ops->remove)
- icd->ops->remove(icd);
+ if (icd->remove)
+ icd->remove(icd);
return 0;
}
@@ -776,27 +760,12 @@ static void dummy_release(struct device *dev)
{
}
-static spinlock_t *spinlock_alloc(struct soc_camera_file *icf)
-{
- spinlock_t *lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL);
-
- if (lock)
- spin_lock_init(lock);
-
- return lock;
-}
-
-static void spinlock_free(spinlock_t *lock)
-{
- kfree(lock);
-}
-
-int soc_camera_host_register(struct soc_camera_host *ici)
+int soc_camera_host_register(struct soc_camera_host *ici, struct module *owner)
{
int ret;
struct soc_camera_host *ix;
- if (!ici->vbq_ops || !ici->ops->add || !ici->ops->remove)
+ if (!ici->vbq_ops || !ici->add || !ici->remove || !owner)
return -EINVAL;
/* Number might be equal to the platform device ID */
@@ -814,6 +783,7 @@ int soc_camera_host_register(struct soc_camera_host *ici)
list_add_tail(&ici->list, &hosts);
mutex_unlock(&list_lock);
+ ici->owner = owner;
ici->dev.release = dummy_release;
ret = device_register(&ici->dev);
@@ -821,11 +791,6 @@ int soc_camera_host_register(struct soc_camera_host *ici)
if (ret)
goto edevr;
- if (!ici->ops->spinlock_alloc) {
- ici->ops->spinlock_alloc = spinlock_alloc;
- ici->ops->spinlock_free = spinlock_free;
- }
-
scan_add_host(ici);
return 0;
@@ -852,7 +817,7 @@ void soc_camera_host_unregister(struct soc_camera_host *ici)
if (icd->dev.parent == &ici->dev) {
device_unregister(&icd->dev);
/* Not before device_unregister(), .remove
- * needs parent to call ici->ops->remove() */
+ * needs parent to call ici->remove() */
icd->dev.parent = NULL;
memset(&icd->dev.kobj, 0, sizeof(icd->dev.kobj));
}
@@ -895,6 +860,9 @@ int soc_camera_device_register(struct soc_camera_device *icd)
icd->dev.release = dummy_release;
+ if (icd->ops->get_datawidth)
+ icd->cached_datawidth = icd->ops->get_datawidth(icd);
+
return scan_add_device(icd);
}
EXPORT_SYMBOL(soc_camera_device_register);
@@ -961,7 +929,7 @@ int soc_camera_video_start(struct soc_camera_device *icd)
vdev->vidioc_s_register = soc_camera_s_register;
#endif
- icd->current_fmt = &icd->formats[0];
+ icd->current_fmt = &icd->ops->formats[0];
err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor);
if (err < 0) {
diff --git a/linux/include/asm-arm/arch-pxa/pxa-regs.h b/linux/include/asm-arm/arch-pxa/pxa-regs.h
index b65a3a789..368b2297c 100644
--- a/linux/include/asm-arm/arch-pxa/pxa-regs.h
+++ b/linux/include/asm-arm/arch-pxa/pxa-regs.h
@@ -1248,26 +1248,19 @@
#define GPIO10_RTCCLK 10 /* real time clock (1 Hz) */
#define GPIO11_3_6MHz 11 /* 3.6 MHz oscillator out */
#define GPIO12_32KHz 12 /* 32 kHz out */
-#define GPIO12_CIF_DD7 12 /* Capture Interface D7 (PXA27x) */
#define GPIO13_MBGNT 13 /* memory controller grant */
#define GPIO14_MBREQ 14 /* alternate bus master request */
#define GPIO15_nCS_1 15 /* chip select 1 */
#define GPIO16_PWM0 16 /* PWM0 output */
#define GPIO17_PWM1 17 /* PWM1 output */
-#define GPIO17_CIF_DD6 17 /* Capture Interface D6 (PXA27x) */
#define GPIO18_RDY 18 /* Ext. Bus Ready */
#define GPIO19_DREQ1 19 /* External DMA Request */
#define GPIO20_DREQ0 20 /* External DMA Request */
#define GPIO23_SCLK 23 /* SSP clock */
-#define GPIO23_CIF_MCLK 23 /* Capture Interface MCLK (PXA27x) */
#define GPIO24_SFRM 24 /* SSP Frame */
-#define GPIO24_CIF_FV 24 /* Capture Interface FV (PXA27x) */
#define GPIO25_STXD 25 /* SSP transmit */
-#define GPIO25_CIF_LV 25 /* Capture Interface LV (PXA27x) */
#define GPIO26_SRXD 26 /* SSP receive */
-#define GPIO26_CIF_PCLK 26 /* Capture Interface PCLK (PXA27x) */
#define GPIO27_SEXTCLK 27 /* SSP ext_clk */
-#define GPIO27_CIF_DD0 27 /* Capture Interface D0 (PXA27x) */
#define GPIO28_BITCLK 28 /* AC97/I2S bit_clk */
#define GPIO29_SDATA_IN 29 /* AC97 Sdata_in0 / I2S Sdata_in */
#define GPIO30_SDATA_OUT 30 /* AC97/I2S Sdata_out */
@@ -1288,40 +1281,28 @@
#define GPIO41_FFRTS 41 /* FFUART request to send */
#define GPIO42_BTRXD 42 /* BTUART receive data */
#define GPIO42_HWRXD 42 /* HWUART receive data */
-#define GPIO42_CIF_MCLK 42 /* Capture interface MCLK (PXA27x) */
#define GPIO43_BTTXD 43 /* BTUART transmit data */
#define GPIO43_HWTXD 43 /* HWUART transmit data */
-#define GPIO43_CIF_FV 43 /* Capture interface FV (PXA27x) */
#define GPIO44_BTCTS 44 /* BTUART clear to send */
#define GPIO44_HWCTS 44 /* HWUART clear to send */
-#define GPIO44_CIF_LV 44 /* Capture interface LV (PXA27x) */
#define GPIO45_BTRTS 45 /* BTUART request to send */
#define GPIO45_HWRTS 45 /* HWUART request to send */
#define GPIO45_AC97_SYSCLK 45 /* AC97 System Clock */
-#define GPIO45_CIF_PCLK 45 /* Capture interface PCLK (PXA27x) */
#define GPIO46_ICPRXD 46 /* ICP receive data */
#define GPIO46_STRXD 46 /* STD_UART receive data */
#define GPIO47_ICPTXD 47 /* ICP transmit data */
#define GPIO47_STTXD 47 /* STD_UART transmit data */
-#define GPIO47_CIF_DD0 47 /* Capture interface D0 (PXA27x) */
#define GPIO48_nPOE 48 /* Output Enable for Card Space */
-#define GPIO48_CIF_DD5 48 /* Capture interface D5 (PXA27x) */
#define GPIO49_nPWE 49 /* Write Enable for Card Space */
#define GPIO50_nPIOR 50 /* I/O Read for Card Space */
-#define GPIO50_CIF_DD3 50 /* Capture interface D3 (PXA27x) */
#define GPIO51_nPIOW 51 /* I/O Write for Card Space */
-#define GPIO51_CIF_DD2 51 /* Capture interface D2 (PXA27x) */
#define GPIO52_nPCE_1 52 /* Card Enable for Card Space */
-#define GPIO52_CIF_DD4 52 /* Capture interface D4 (PXA27x) */
#define GPIO53_nPCE_2 53 /* Card Enable for Card Space */
#define GPIO53_MMCCLK 53 /* MMC Clock */
-#define GPIO53_CIF_MCLK 53 /* Capture interface MCLK (PXA27x) */
#define GPIO54_MMCCLK 54 /* MMC Clock */
#define GPIO54_pSKTSEL 54 /* Socket Select for Card Space */
#define GPIO54_nPCE_2 54 /* Card Enable for Card Space (PXA27x) */
-#define GPIO54_CIF_PCLK 54 /* Capture interface PCLK (PXA27x) */
#define GPIO55_nPREG 55 /* Card Address bit 26 */
-#define GPIO55_CIF_DD1 55 /* Capture interface D1 (PXA27x) */
#define GPIO56_nPWAIT 56 /* Wait signal for Card Space */
#define GPIO57_nIOIS16 57 /* Bus Width select for I/O Card Space */
#define GPIO58_LDD_0 58 /* LCD data pin 0 */
@@ -1356,28 +1337,11 @@
#define GPIO79_nCS_3 79 /* chip select 3 */
#define GPIO80_nCS_4 80 /* chip select 4 */
#define GPIO81_NSCLK 81 /* NSSP clock */
-#define GPIO81_CIF_DD0 81 /* Capture Interface D0 (PXA27x) */
#define GPIO82_NSFRM 82 /* NSSP Frame */
-#define GPIO82_CIF_DD5 82 /* Capture Interface D5 (PXA27x) */
#define GPIO83_NSTXD 83 /* NSSP transmit */
-#define GPIO83_CIF_DD4 83 /* Capture Interface D4 (PXA27x) */
#define GPIO84_NSRXD 84 /* NSSP receive */
-#define GPIO84_CIF_FV 84 /* Capture Interface FV (PXA27x) */
#define GPIO85_nPCE_1 85 /* Card Enable for Card Space (PXA27x) */
-#define GPIO85_CIF_LV 85 /* Capture Interface LV (PXA27x) */
-#define GPIO90_CIF_DD4 90 /* Capture Interface DD4 (PXA27x) */
-#define GPIO91_CIF_DD5 91 /* Capture Interface DD5 (PXA27x) */
#define GPIO92_MMCDAT0 92 /* MMC DAT0 (PXA27x) */
-#define GPIO93_CIF_DD6 93 /* Capture interface D6 (PXA27x) */
-#define GPIO94_CIF_DD5 94 /* Capture interface D5 (PXA27x) */
-#define GPIO95_CIF_DD4 95 /* Capture interface D4 (PXA27x) */
-#define GPIO98_CIF_DD0 98 /* Capture interface D0 (PXA27x) */
-#define GPIO103_CIF_DD3 103 /* Capture interface D3 (PXA27x) */
-#define GPIO104_CIF_DD2 104 /* Capture interface D2 (PXA27x) */
-#define GPIO105_CIF_DD1 105 /* Capture interface D1 (PXA27x) */
-#define GPIO106_CIF_DD9 106 /* Capture interface D9 (PXA27x) */
-#define GPIO107_CIF_DD8 107 /* Capture interface D8 (PXA27x) */
-#define GPIO108_CIF_DD7 108 /* Capture interface D7 (PXA27x) */
#define GPIO102_nPCE_1 102 /* PCMCIA (PXA27x) */
#define GPIO109_MMCDAT1 109 /* MMC DAT1 (PXA27x) */
#define GPIO110_MMCDAT2 110 /* MMC DAT2 (PXA27x) */
@@ -1387,9 +1351,6 @@
#define GPIO112_MMCCMD 112 /* MMC CMD (PXA27x) */
#define GPIO113_I2S_SYSCLK 113 /* I2S System Clock (PXA27x) */
#define GPIO113_AC97_RESET_N 113 /* AC97 NRESET on (PXA27x) */
-#define GPIO114_CIF_DD1 114 /* Capture interface D1 (PXA27x) */
-#define GPIO115_CIF_DD3 115 /* Capture interface D3 (PXA27x) */
-#define GPIO116_CIF_DD2 116 /* Capture interface D2 (PXA27x) */
/* GPIO alternate function mode & direction */
@@ -1415,26 +1376,19 @@
#define GPIO10_RTCCLK_MD (10 | GPIO_ALT_FN_1_OUT)
#define GPIO11_3_6MHz_MD (11 | GPIO_ALT_FN_1_OUT)
#define GPIO12_32KHz_MD (12 | GPIO_ALT_FN_1_OUT)
-#define GPIO12_CIF_DD7_MD (12 | GPIO_ALT_FN_2_IN)
#define GPIO13_MBGNT_MD (13 | GPIO_ALT_FN_2_OUT)
#define GPIO14_MBREQ_MD (14 | GPIO_ALT_FN_1_IN)
#define GPIO15_nCS_1_MD (15 | GPIO_ALT_FN_2_OUT)
#define GPIO16_PWM0_MD (16 | GPIO_ALT_FN_2_OUT)
#define GPIO17_PWM1_MD (17 | GPIO_ALT_FN_2_OUT)
-#define GPIO17_CIF_DD6_MD (17 | GPIO_ALT_FN_2_IN)
#define GPIO18_RDY_MD (18 | GPIO_ALT_FN_1_IN)
#define GPIO19_DREQ1_MD (19 | GPIO_ALT_FN_1_IN)
#define GPIO20_DREQ0_MD (20 | GPIO_ALT_FN_1_IN)
-#define GPIO23_CIF_MCLK_MD (23 | GPIO_ALT_FN_1_OUT)
#define GPIO23_SCLK_MD (23 | GPIO_ALT_FN_2_OUT)
-#define GPIO24_CIF_FV_MD (24 | GPIO_ALT_FN_1_OUT)
#define GPIO24_SFRM_MD (24 | GPIO_ALT_FN_2_OUT)
-#define GPIO25_CIF_LV_MD (25 | GPIO_ALT_FN_1_OUT)
#define GPIO25_STXD_MD (25 | GPIO_ALT_FN_2_OUT)
#define GPIO26_SRXD_MD (26 | GPIO_ALT_FN_1_IN)
-#define GPIO26_CIF_PCLK_MD (26 | GPIO_ALT_FN_2_IN)
#define GPIO27_SEXTCLK_MD (27 | GPIO_ALT_FN_1_IN)
-#define GPIO27_CIF_DD0_MD (27 | GPIO_ALT_FN_3_IN)
#define GPIO28_BITCLK_AC97_MD (28 | GPIO_ALT_FN_1_IN)
#define GPIO28_BITCLK_IN_I2S_MD (28 | GPIO_ALT_FN_2_IN)
#define GPIO28_BITCLK_OUT_I2S_MD (28 | GPIO_ALT_FN_1_OUT)
@@ -1459,46 +1413,34 @@
#define GPIO40_FFDTR_MD (40 | GPIO_ALT_FN_2_OUT)
#define GPIO41_FFRTS_MD (41 | GPIO_ALT_FN_2_OUT)
#define GPIO42_BTRXD_MD (42 | GPIO_ALT_FN_1_IN)
-#define GPIO42_CIF_MCLK_MD (42 | GPIO_ALT_FN_3_OUT)
#define GPIO42_HWRXD_MD (42 | GPIO_ALT_FN_3_IN)
#define GPIO43_BTTXD_MD (43 | GPIO_ALT_FN_2_OUT)
-#define GPIO43_CIF_FV_MD (43 | GPIO_ALT_FN_3_OUT)
#define GPIO43_HWTXD_MD (43 | GPIO_ALT_FN_3_OUT)
#define GPIO44_BTCTS_MD (44 | GPIO_ALT_FN_1_IN)
#define GPIO44_HWCTS_MD (44 | GPIO_ALT_FN_3_IN)
-#define GPIO44_CIF_LV_MD (44 | GPIO_ALT_FN_3_OUT)
#define GPIO45_BTRTS_MD (45 | GPIO_ALT_FN_2_OUT)
#define GPIO45_HWRTS_MD (45 | GPIO_ALT_FN_3_OUT)
#define GPIO45_SYSCLK_AC97_MD (45 | GPIO_ALT_FN_1_OUT)
-#define GPIO45_CIF_PCLK_MD (45 | GPIO_ALT_FN_3_IN)
#define GPIO46_ICPRXD_MD (46 | GPIO_ALT_FN_1_IN)
#define GPIO46_STRXD_MD (46 | GPIO_ALT_FN_2_IN)
#define GPIO47_ICPTXD_MD (47 | GPIO_ALT_FN_2_OUT)
#define GPIO47_STTXD_MD (47 | GPIO_ALT_FN_1_OUT)
-#define GPIO47_CIF_DD0_MD (47 | GPIO_ALT_FN_1_IN)
#define GPIO48_nPOE_MD (48 | GPIO_ALT_FN_2_OUT)
-#define GPIO48_CIF_DD5_MD (48 | GPIO_ALT_FN_1_IN)
#define GPIO48_HWTXD_MD (48 | GPIO_ALT_FN_1_OUT)
#define GPIO48_nPOE_MD (48 | GPIO_ALT_FN_2_OUT)
#define GPIO49_HWRXD_MD (49 | GPIO_ALT_FN_1_IN)
#define GPIO49_nPWE_MD (49 | GPIO_ALT_FN_2_OUT)
#define GPIO50_nPIOR_MD (50 | GPIO_ALT_FN_2_OUT)
-#define GPIO50_CIF_DD3_MD (50 | GPIO_ALT_FN_1_IN)
#define GPIO50_HWCTS_MD (50 | GPIO_ALT_FN_1_IN)
#define GPIO51_HWRTS_MD (51 | GPIO_ALT_FN_1_OUT)
#define GPIO51_nPIOW_MD (51 | GPIO_ALT_FN_2_OUT)
-#define GPIO51_CIF_DD2_MD (51 | GPIO_ALT_FN_1_IN)
#define GPIO52_nPCE_1_MD (52 | GPIO_ALT_FN_2_OUT)
-#define GPIO52_CIF_DD4_MD (52 | GPIO_ALT_FN_1_IN)
#define GPIO53_nPCE_2_MD (53 | GPIO_ALT_FN_2_OUT)
#define GPIO53_MMCCLK_MD (53 | GPIO_ALT_FN_1_OUT)
-#define GPIO53_CIF_MCLK_MD (53 | GPIO_ALT_FN_2_OUT)
#define GPIO54_MMCCLK_MD (54 | GPIO_ALT_FN_1_OUT)
#define GPIO54_nPCE_2_MD (54 | GPIO_ALT_FN_2_OUT)
#define GPIO54_pSKTSEL_MD (54 | GPIO_ALT_FN_2_OUT)
-#define GPIO54_CIF_PCLK_MD (54 | GPIO_ALT_FN_3_IN)
#define GPIO55_nPREG_MD (55 | GPIO_ALT_FN_2_OUT)
-#define GPIO55_CIF_DD1_MD (55 | GPIO_ALT_FN_1_IN)
#define GPIO56_nPWAIT_MD (56 | GPIO_ALT_FN_1_IN)
#define GPIO57_nIOIS16_MD (57 | GPIO_ALT_FN_1_IN)
#define GPIO58_LDD_0_MD (58 | GPIO_ALT_FN_2_OUT)
@@ -1535,33 +1477,16 @@
#define GPIO80_nCS_4_MD (80 | GPIO_ALT_FN_2_OUT)
#define GPIO81_NSSP_CLK_OUT (81 | GPIO_ALT_FN_1_OUT)
#define GPIO81_NSSP_CLK_IN (81 | GPIO_ALT_FN_1_IN)
-#define GPIO81_CIF_DD0_MD (81 | GPIO_ALT_FN_2_IN)
#define GPIO82_NSSP_FRM_OUT (82 | GPIO_ALT_FN_1_OUT)
#define GPIO82_NSSP_FRM_IN (82 | GPIO_ALT_FN_1_IN)
-#define GPIO82_CIF_DD5_MD (82 | GPIO_ALT_FN_3_IN)
#define GPIO83_NSSP_TX (83 | GPIO_ALT_FN_1_OUT)
#define GPIO83_NSSP_RX (83 | GPIO_ALT_FN_2_IN)
-#define GPIO83_CIF_DD4_MD (83 | GPIO_ALT_FN_3_IN)
#define GPIO84_NSSP_TX (84 | GPIO_ALT_FN_1_OUT)
#define GPIO84_NSSP_RX (84 | GPIO_ALT_FN_2_IN)
-#define GPIO84_CIF_FV_MD (84 | GPIO_ALT_FN_3_OUT)
#define GPIO85_nPCE_1_MD (85 | GPIO_ALT_FN_1_OUT)
-#define GPIO85_CIF_LV_MD (85 | GPIO_ALT_FN_3_OUT)
-#define GPIO90_CIF_DD4_MD (90 | GPIO_ALT_FN_3_IN)
-#define GPIO91_CIF_DD5_MD (91 | GPIO_ALT_FN_3_IN)
#define GPIO92_MMCDAT0_MD (92 | GPIO_ALT_FN_1_OUT)
-#define GPIO93_CIF_DD6_MD (93 | GPIO_ALT_FN_2_IN)
-#define GPIO94_CIF_DD5_MD (94 | GPIO_ALT_FN_2_IN)
-#define GPIO95_CIF_DD4_MD (95 | GPIO_ALT_FN_2_IN)
-#define GPIO98_CIF_DD0_MD (98 | GPIO_ALT_FN_2_IN)
#define GPIO102_nPCE_1_MD (102 | GPIO_ALT_FN_1_OUT)
-#define GPIO103_CIF_DD3_MD (103 | GPIO_ALT_FN_1_IN)
#define GPIO104_pSKTSEL_MD (104 | GPIO_ALT_FN_1_OUT)
-#define GPIO104_CIF_DD2_MD (104 | GPIO_ALT_FN_1_IN)
-#define GPIO105_CIF_DD1_MD (105 | GPIO_ALT_FN_1_IN)
-#define GPIO106_CIF_DD9_MD (106 | GPIO_ALT_FN_1_IN)
-#define GPIO107_CIF_DD8_MD (107 | GPIO_ALT_FN_1_IN)
-#define GPIO108_CIF_DD7_MD (108 | GPIO_ALT_FN_1_IN)
#define GPIO109_MMCDAT1_MD (109 | GPIO_ALT_FN_1_OUT)
#define GPIO110_MMCDAT2_MD (110 | GPIO_ALT_FN_1_OUT)
#define GPIO110_MMCCS0_MD (110 | GPIO_ALT_FN_1_OUT)
@@ -1840,11 +1765,6 @@
/* [1..256 Tpix] */ \
(((Tpix) - 1) << FShft (LCCR1_BLW))
-#if 0
-#define LCCR3_PCD (0xff) /* Pixel clock divisor */
-#define LCCR3_ACB (0xff << 8) /* AC Bias pin frequency */
-#define LCCR3_ACB_S 8
-#endif
#define LCCR2_LPP Fld (10, 0) /* Line Per Panel - 1 */
#define LCCR2_DisHght(Line) /* Display Height [1..1024 lines] */ \
diff --git a/linux/include/media/soc_camera.h b/linux/include/media/soc_camera.h
index 6a8c8be7a..c886b1e64 100644
--- a/linux/include/media/soc_camera.h
+++ b/linux/include/media/soc_camera.h
@@ -34,12 +34,12 @@ struct soc_camera_device {
unsigned short exposure;
unsigned char iface; /* Host number */
unsigned char devnum; /* Device number per host */
- unsigned char buswidth; /* See comment in .c */
+ unsigned char cached_datawidth; /* See comment in .c */
struct soc_camera_ops *ops;
struct video_device *vdev;
const struct soc_camera_data_format *current_fmt;
- const struct soc_camera_data_format *formats;
- int num_formats;
+ int (*probe)(struct soc_camera_device *icd);
+ void (*remove)(struct soc_camera_device *icd);
struct module *owner;
/* soc_camera.c private count. Only accessed with video_lock held */
int use_count;
@@ -48,7 +48,6 @@ struct soc_camera_device {
struct soc_camera_file {
struct soc_camera_device *icd;
struct videobuf_queue vb_vidq;
- spinlock_t *lock;
};
struct soc_camera_host {
@@ -57,25 +56,17 @@ struct soc_camera_host {
unsigned char nr; /* Host number */
size_t msize;
struct videobuf_queue_ops *vbq_ops;
+ struct module *owner;
void *priv;
char *drv_name;
- struct soc_camera_host_ops *ops;
-};
-
-struct soc_camera_host_ops {
- struct module *owner;
int (*add)(struct soc_camera_device *);
void (*remove)(struct soc_camera_device *);
- int (*set_fmt_cap)(struct soc_camera_device *, __u32,
- struct v4l2_rect *);
- int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
+ int (*set_capture_format)(struct soc_camera_device *, __u32,
+ struct v4l2_rect *);
+ int (*try_fmt_cap)(struct soc_camera_host *, struct v4l2_format *);
int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *);
int (*querycap)(struct soc_camera_host *, struct v4l2_capability *);
- int (*try_bus_param)(struct soc_camera_device *, __u32);
- int (*set_bus_param)(struct soc_camera_device *, __u32);
unsigned int (*poll)(struct file *, poll_table *);
- spinlock_t* (*spinlock_alloc)(struct soc_camera_file *);
- void (*spinlock_free)(spinlock_t *);
};
struct soc_camera_link {
@@ -95,7 +86,8 @@ static inline struct soc_camera_host *to_soc_camera_host(struct device *dev)
return container_of(dev, struct soc_camera_host, dev);
}
-extern int soc_camera_host_register(struct soc_camera_host *ici);
+extern int soc_camera_host_register(struct soc_camera_host *ici,
+ struct module *owner);
extern void soc_camera_host_unregister(struct soc_camera_host *ici);
extern int soc_camera_device_register(struct soc_camera_device *icd);
extern void soc_camera_device_unregister(struct soc_camera_device *icd);
@@ -112,27 +104,26 @@ struct soc_camera_data_format {
struct soc_camera_ops {
struct module *owner;
- int (*probe)(struct soc_camera_device *);
- void (*remove)(struct soc_camera_device *);
int (*init)(struct soc_camera_device *);
int (*release)(struct soc_camera_device *);
int (*start_capture)(struct soc_camera_device *);
int (*stop_capture)(struct soc_camera_device *);
- int (*set_fmt_cap)(struct soc_camera_device *, __u32,
- struct v4l2_rect *);
+ int (*set_capture_format)(struct soc_camera_device *, __u32,
+ struct v4l2_rect *, unsigned int);
int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *);
- unsigned long (*query_bus_param)(struct soc_camera_device *);
- int (*set_bus_param)(struct soc_camera_device *, unsigned long);
int (*get_chip_id)(struct soc_camera_device *,
struct v4l2_chip_ident *);
#ifdef CONFIG_VIDEO_ADV_DEBUG
int (*get_register)(struct soc_camera_device *, struct v4l2_register *);
int (*set_register)(struct soc_camera_device *, struct v4l2_register *);
#endif
+ const struct soc_camera_data_format *formats;
+ int num_formats;
int (*get_control)(struct soc_camera_device *, struct v4l2_control *);
int (*set_control)(struct soc_camera_device *, struct v4l2_control *);
const struct v4l2_queryctrl *controls;
int num_controls;
+ unsigned int(*get_datawidth)(struct soc_camera_device *icd);
};
static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
@@ -147,33 +138,12 @@ static inline struct v4l2_queryctrl const *soc_camera_find_qctrl(
return NULL;
}
-#define SOCAM_MASTER (1 << 0)
-#define SOCAM_SLAVE (1 << 1)
-#define SOCAM_HSYNC_ACTIVE_HIGH (1 << 2)
-#define SOCAM_HSYNC_ACTIVE_LOW (1 << 3)
-#define SOCAM_VSYNC_ACTIVE_HIGH (1 << 4)
-#define SOCAM_VSYNC_ACTIVE_LOW (1 << 5)
-#define SOCAM_DATAWIDTH_8 (1 << 6)
-#define SOCAM_DATAWIDTH_9 (1 << 7)
-#define SOCAM_DATAWIDTH_10 (1 << 8)
-#define SOCAM_PCLK_SAMPLE_RISING (1 << 9)
-#define SOCAM_PCLK_SAMPLE_FALLING (1 << 10)
-
-#define SOCAM_DATAWIDTH_MASK (SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_9 | \
- SOCAM_DATAWIDTH_10)
-
-static inline unsigned long soc_camera_bus_param_compatible(
- unsigned long camera_flags, unsigned long bus_flags)
-{
- unsigned long common_flags, hsync, vsync, pclk;
-
- common_flags = camera_flags & bus_flags;
-
- hsync = common_flags & (SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW);
- vsync = common_flags & (SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW);
- pclk = common_flags & (SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING);
-
- return (!hsync || !vsync || !pclk) ? 0 : common_flags;
-}
+#define IS_MASTER (1<<0)
+#define IS_HSYNC_ACTIVE_HIGH (1<<1)
+#define IS_VSYNC_ACTIVE_HIGH (1<<2)
+#define IS_DATAWIDTH_8 (1<<3)
+#define IS_DATAWIDTH_9 (1<<4)
+#define IS_DATAWIDTH_10 (1<<5)
+#define IS_PCLK_SAMPLE_RISING (1<<6)
#endif