diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-15 12:12:36 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-15 12:12:36 -0300 |
commit | d8006eead13b16a2cd2fbaa0bcf07a6944798344 (patch) | |
tree | 63e2ee9c61fbba1f9e3c2fe3b20ee20c04a8b67a /linux/drivers/media/video | |
parent | 0b19553adedb9b1ee222def2c7d8e3e748038d31 (diff) | |
download | mediapointer-dvb-s2-d8006eead13b16a2cd2fbaa0bcf07a6944798344.tar.gz mediapointer-dvb-s2-d8006eead13b16a2cd2fbaa0bcf07a6944798344.tar.bz2 |
> Please, re-generate the affected V4L/DVB patches, without the PXA part. I'll
> keep those changes on hold, until I get a confirmation that the PXA side is
> committed on mainstream.
Reverted several changes on soc_camera
From: Mauro Carvalho Chehab <mchehab@infradead.org>
As asked by Guennadi:
Mauro, please, drop commits 2f4a87873f13924871d7bb82e27d02d0e16fbe02 and
9b7d577c508e7765860e599c0e98d4ac3fbaa2aa from your tree and replace
5f1e5244ee6b9f139a262d5e7a930a41488afbbe with the version below.
Due to that change, that happened on v4l-dvb -git tree, several patches broke.
This patch reverts all broken stuff, keeping this tree in sync with v4l-dvb
-git tree.
I'm waiting for Guennadi to fix the broken patches and ask me to pull them
again.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video')
-rw-r--r-- | linux/drivers/media/video/mt9m001.c | 101 | ||||
-rw-r--r-- | linux/drivers/media/video/mt9v022.c | 155 | ||||
-rw-r--r-- | linux/drivers/media/video/pxa_camera.c | 317 | ||||
-rw-r--r-- | linux/drivers/media/video/soc_camera.c | 144 |
4 files changed, 289 insertions, 428 deletions
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) { |