[media] pxa_camera: allow building it if COMPILE_TEST is set
[deliverable/linux.git] / drivers / media / platform / pxa_camera.c
CommitLineData
3bc43840
GL
1/*
2 * V4L2 Driver for PXA camera host
3 *
4 * Copyright (C) 2006, Sascha Hauer, Pengutronix
5 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
283e4a82 6 * Copyright (C) 2016, Robert Jarzmik <robert.jarzmik@free.fr>
3bc43840
GL
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
3bc43840
GL
14#include <linux/init.h>
15#include <linux/module.h>
7102b773 16#include <linux/io.h>
3bc43840 17#include <linux/delay.h>
283e4a82 18#include <linux/device.h>
3bc43840 19#include <linux/dma-mapping.h>
8efdb135 20#include <linux/err.h>
3bc43840
GL
21#include <linux/errno.h>
22#include <linux/fs.h>
23#include <linux/interrupt.h>
24#include <linux/kernel.h>
25#include <linux/mm.h>
26#include <linux/moduleparam.h>
283e4a82 27#include <linux/of.h>
3bc43840 28#include <linux/time.h>
3bc43840
GL
29#include <linux/device.h>
30#include <linux/platform_device.h>
3bc43840 31#include <linux/clk.h>
d514edac 32#include <linux/sched.h>
5a0e3ad6 33#include <linux/slab.h>
1e77d55a
RJ
34#include <linux/dmaengine.h>
35#include <linux/dma-mapping.h>
36#include <linux/dma/pxa-dma.h>
3bc43840 37
283e4a82
RJ
38#include <media/v4l2-async.h>
39#include <media/v4l2-clk.h>
3bc43840 40#include <media/v4l2-common.h>
283e4a82
RJ
41#include <media/v4l2-device.h>
42#include <media/v4l2-ioctl.h>
e9a1d94f 43#include <media/v4l2-of.h>
3bc43840 44
283e4a82
RJ
45#include <media/drv-intf/soc_mediabus.h>
46#include <media/videobuf2-dma-sg.h>
47
3bc43840
GL
48#include <linux/videodev2.h>
49
a71daaa1 50#include <linux/platform_data/media/camera-pxa.h>
3bc43840 51
64dc3c1a 52#define PXA_CAM_VERSION "0.0.6"
3bc43840
GL
53#define PXA_CAM_DRV_NAME "pxa27x-camera"
54
283e4a82
RJ
55#define DEFAULT_WIDTH 640
56#define DEFAULT_HEIGHT 480
57
5ca11fa3
EM
58/* Camera Interface */
59#define CICR0 0x0000
60#define CICR1 0x0004
61#define CICR2 0x0008
62#define CICR3 0x000C
63#define CICR4 0x0010
64#define CISR 0x0014
65#define CIFR 0x0018
66#define CITOR 0x001C
67#define CIBR0 0x0028
68#define CIBR1 0x0030
69#define CIBR2 0x0038
70
71#define CICR0_DMAEN (1 << 31) /* DMA request enable */
72#define CICR0_PAR_EN (1 << 30) /* Parity enable */
73#define CICR0_SL_CAP_EN (1 << 29) /* Capture enable for slave mode */
74#define CICR0_ENB (1 << 28) /* Camera interface enable */
75#define CICR0_DIS (1 << 27) /* Camera interface disable */
76#define CICR0_SIM (0x7 << 24) /* Sensor interface mode mask */
77#define CICR0_TOM (1 << 9) /* Time-out mask */
78#define CICR0_RDAVM (1 << 8) /* Receive-data-available mask */
79#define CICR0_FEM (1 << 7) /* FIFO-empty mask */
80#define CICR0_EOLM (1 << 6) /* End-of-line mask */
81#define CICR0_PERRM (1 << 5) /* Parity-error mask */
82#define CICR0_QDM (1 << 4) /* Quick-disable mask */
83#define CICR0_CDM (1 << 3) /* Disable-done mask */
84#define CICR0_SOFM (1 << 2) /* Start-of-frame mask */
85#define CICR0_EOFM (1 << 1) /* End-of-frame mask */
86#define CICR0_FOM (1 << 0) /* FIFO-overrun mask */
87
88#define CICR1_TBIT (1 << 31) /* Transparency bit */
89#define CICR1_RGBT_CONV (0x3 << 29) /* RGBT conversion mask */
90#define CICR1_PPL (0x7ff << 15) /* Pixels per line mask */
91#define CICR1_RGB_CONV (0x7 << 12) /* RGB conversion mask */
92#define CICR1_RGB_F (1 << 11) /* RGB format */
93#define CICR1_YCBCR_F (1 << 10) /* YCbCr format */
94#define CICR1_RGB_BPP (0x7 << 7) /* RGB bis per pixel mask */
95#define CICR1_RAW_BPP (0x3 << 5) /* Raw bis per pixel mask */
96#define CICR1_COLOR_SP (0x3 << 3) /* Color space mask */
97#define CICR1_DW (0x7 << 0) /* Data width mask */
98
99#define CICR2_BLW (0xff << 24) /* Beginning-of-line pixel clock
100 wait count mask */
101#define CICR2_ELW (0xff << 16) /* End-of-line pixel clock
102 wait count mask */
103#define CICR2_HSW (0x3f << 10) /* Horizontal sync pulse width mask */
104#define CICR2_BFPW (0x3f << 3) /* Beginning-of-frame pixel clock
105 wait count mask */
106#define CICR2_FSW (0x7 << 0) /* Frame stabilization
107 wait count mask */
108
109#define CICR3_BFW (0xff << 24) /* Beginning-of-frame line clock
110 wait count mask */
111#define CICR3_EFW (0xff << 16) /* End-of-frame line clock
112 wait count mask */
113#define CICR3_VSW (0x3f << 10) /* Vertical sync pulse width mask */
114#define CICR3_BFPW (0x3f << 3) /* Beginning-of-frame pixel clock
115 wait count mask */
116#define CICR3_LPF (0x7ff << 0) /* Lines per frame mask */
117
118#define CICR4_MCLK_DLY (0x3 << 24) /* MCLK Data Capture Delay mask */
119#define CICR4_PCLK_EN (1 << 23) /* Pixel clock enable */
120#define CICR4_PCP (1 << 22) /* Pixel clock polarity */
121#define CICR4_HSP (1 << 21) /* Horizontal sync polarity */
122#define CICR4_VSP (1 << 20) /* Vertical sync polarity */
123#define CICR4_MCLK_EN (1 << 19) /* MCLK enable */
124#define CICR4_FR_RATE (0x7 << 8) /* Frame rate mask */
125#define CICR4_DIV (0xff << 0) /* Clock divisor mask */
126
127#define CISR_FTO (1 << 15) /* FIFO time-out */
128#define CISR_RDAV_2 (1 << 14) /* Channel 2 receive data available */
129#define CISR_RDAV_1 (1 << 13) /* Channel 1 receive data available */
130#define CISR_RDAV_0 (1 << 12) /* Channel 0 receive data available */
131#define CISR_FEMPTY_2 (1 << 11) /* Channel 2 FIFO empty */
132#define CISR_FEMPTY_1 (1 << 10) /* Channel 1 FIFO empty */
133#define CISR_FEMPTY_0 (1 << 9) /* Channel 0 FIFO empty */
134#define CISR_EOL (1 << 8) /* End of line */
135#define CISR_PAR_ERR (1 << 7) /* Parity error */
136#define CISR_CQD (1 << 6) /* Camera interface quick disable */
137#define CISR_CDD (1 << 5) /* Camera interface disable done */
138#define CISR_SOF (1 << 4) /* Start of frame */
139#define CISR_EOF (1 << 3) /* End of frame */
140#define CISR_IFO_2 (1 << 2) /* FIFO overrun for Channel 2 */
141#define CISR_IFO_1 (1 << 1) /* FIFO overrun for Channel 1 */
142#define CISR_IFO_0 (1 << 0) /* FIFO overrun for Channel 0 */
143
144#define CIFR_FLVL2 (0x7f << 23) /* FIFO 2 level mask */
145#define CIFR_FLVL1 (0x7f << 16) /* FIFO 1 level mask */
146#define CIFR_FLVL0 (0xff << 8) /* FIFO 0 level mask */
147#define CIFR_THL_0 (0x3 << 4) /* Threshold Level for Channel 0 FIFO */
148#define CIFR_RESET_F (1 << 3) /* Reset input FIFOs */
149#define CIFR_FEN2 (1 << 2) /* FIFO enable for channel 2 */
150#define CIFR_FEN1 (1 << 1) /* FIFO enable for channel 1 */
151#define CIFR_FEN0 (1 << 0) /* FIFO enable for channel 0 */
152
7102b773
GL
153#define CICR0_SIM_MP (0 << 24)
154#define CICR0_SIM_SP (1 << 24)
155#define CICR0_SIM_MS (2 << 24)
156#define CICR0_SIM_EP (3 << 24)
157#define CICR0_SIM_ES (4 << 24)
158
159#define CICR1_DW_VAL(x) ((x) & CICR1_DW) /* Data bus width */
160#define CICR1_PPL_VAL(x) (((x) << 15) & CICR1_PPL) /* Pixels per line */
a5462e5b
MR
161#define CICR1_COLOR_SP_VAL(x) (((x) << 3) & CICR1_COLOR_SP) /* color space */
162#define CICR1_RGB_BPP_VAL(x) (((x) << 7) & CICR1_RGB_BPP) /* bpp for rgb */
163#define CICR1_RGBT_CONV_VAL(x) (((x) << 29) & CICR1_RGBT_CONV) /* rgbt conv */
7102b773
GL
164
165#define CICR2_BLW_VAL(x) (((x) << 24) & CICR2_BLW) /* Beginning-of-line pixel clock wait count */
166#define CICR2_ELW_VAL(x) (((x) << 16) & CICR2_ELW) /* End-of-line pixel clock wait count */
167#define CICR2_HSW_VAL(x) (((x) << 10) & CICR2_HSW) /* Horizontal sync pulse width */
168#define CICR2_BFPW_VAL(x) (((x) << 3) & CICR2_BFPW) /* Beginning-of-frame pixel clock wait count */
169#define CICR2_FSW_VAL(x) (((x) << 0) & CICR2_FSW) /* Frame stabilization wait count */
170
171#define CICR3_BFW_VAL(x) (((x) << 24) & CICR3_BFW) /* Beginning-of-frame line clock wait count */
172#define CICR3_EFW_VAL(x) (((x) << 16) & CICR3_EFW) /* End-of-frame line clock wait count */
173#define CICR3_VSW_VAL(x) (((x) << 11) & CICR3_VSW) /* Vertical sync pulse width */
174#define CICR3_LPF_VAL(x) (((x) << 0) & CICR3_LPF) /* Lines per frame */
175
3bc43840
GL
176#define CICR0_IRQ_MASK (CICR0_TOM | CICR0_RDAVM | CICR0_FEM | CICR0_EOLM | \
177 CICR0_PERRM | CICR0_QDM | CICR0_CDM | CICR0_SOFM | \
178 CICR0_EOFM | CICR0_FOM)
179
b36bcbd6 180#define sensor_call(cam, o, f, args...) \
283e4a82
RJ
181 v4l2_subdev_call(cam->sensor, o, f, ##args)
182
183/*
184 * Format handling
185 */
186/**
187 * struct soc_camera_format_xlate - match between host and sensor formats
188 * @code: code of a sensor provided format
189 * @host_fmt: host format after host translation from code
190 *
191 * Host and sensor translation structure. Used in table of host and sensor
192 * formats matchings in soc_camera_device. A host can override the generic list
193 * generation by implementing get_formats(), and use it for format checks and
194 * format setup.
195 */
196struct soc_camera_format_xlate {
197 u32 code;
198 const struct soc_mbus_pixelfmt *host_fmt;
199};
b36bcbd6 200
3bc43840
GL
201/*
202 * Structures
203 */
a5462e5b
MR
204enum pxa_camera_active_dma {
205 DMA_Y = 0x1,
206 DMA_U = 0x2,
207 DMA_V = 0x4,
208};
209
3bc43840
GL
210/* buffer for one video frame */
211struct pxa_buffer {
212 /* common v4l buffer stuff -- must be first */
e009ebd5
RJ
213 struct vb2_v4l2_buffer vbuf;
214 struct list_head queue;
27ffaeb0 215 u32 code;
e009ebd5 216 int nb_planes;
a5462e5b 217 /* our descriptor lists for Y, U and V channels */
1e77d55a
RJ
218 struct dma_async_tx_descriptor *descs[3];
219 dma_cookie_t cookie[3];
220 struct scatterlist *sg[3];
221 int sg_len[3];
e009ebd5 222 size_t plane_sizes[3];
760697be
GL
223 int inwork;
224 enum pxa_camera_active_dma active_dma;
3bc43840
GL
225};
226
3bc43840 227struct pxa_camera_dev {
283e4a82
RJ
228 struct v4l2_device v4l2_dev;
229 struct video_device vdev;
230 struct v4l2_async_notifier notifier;
231 struct vb2_queue vb2_vq;
232 struct v4l2_subdev *sensor;
233 struct soc_camera_format_xlate *user_formats;
234 const struct soc_camera_format_xlate *current_fmt;
235 struct v4l2_pix_format current_pix;
236
237 struct v4l2_async_subdev asd;
238 struct v4l2_async_subdev *asds[1];
239
5d28d525
GL
240 /*
241 * PXA27x is only supposed to handle one camera on its Quick Capture
3bc43840 242 * interface. If anyone ever builds hardware to enable more than
5d28d525
GL
243 * one camera, they will have to modify this driver too
244 */
3bc43840
GL
245 struct clk *clk;
246
247 unsigned int irq;
248 void __iomem *base;
a5462e5b 249
e7c50688 250 int channels;
1e77d55a 251 struct dma_chan *dma_chans[3];
3bc43840 252
3bc43840
GL
253 struct pxacamera_platform_data *pdata;
254 struct resource *res;
255 unsigned long platform_flags;
cf34cba7
GL
256 unsigned long ciclk;
257 unsigned long mclk;
258 u32 mclk_divisor;
283e4a82 259 struct v4l2_clk *mclk_clk;
679419aa 260 u16 width_flags; /* max 10 bits */
3bc43840
GL
261
262 struct list_head capture;
263
264 spinlock_t lock;
283e4a82 265 struct mutex mlock;
61634976 266 unsigned int buf_sequence;
3bc43840 267
3bc43840 268 struct pxa_buffer *active;
e623ebe6 269 struct tasklet_struct task_eof;
3f6ac497
RJ
270
271 u32 save_cicr[5];
3bc43840
GL
272};
273
6a6c8786
GL
274struct pxa_cam {
275 unsigned long flags;
276};
277
3bc43840
GL
278static const char *pxa_cam_driver_description = "PXA_Camera";
279
283e4a82
RJ
280/*
281 * Format translation functions
282 */
283const struct soc_camera_format_xlate *soc_mbus_xlate_by_fourcc(
284 struct soc_camera_format_xlate *user_formats, unsigned int fourcc)
285{
286 unsigned int i;
287
288 for (i = 0; user_formats[i].code; i++)
289 if (user_formats[i].host_fmt->fourcc == fourcc)
290 return user_formats + i;
291 return NULL;
292}
293
294static struct soc_camera_format_xlate *soc_mbus_build_fmts_xlate(
295 struct v4l2_device *v4l2_dev, struct v4l2_subdev *subdev,
296 int (*get_formats)(struct v4l2_device *, unsigned int,
297 struct soc_camera_format_xlate *xlate))
295ab497 298{
283e4a82
RJ
299 unsigned int i, fmts = 0, raw_fmts = 0;
300 int ret;
301 struct v4l2_subdev_mbus_code_enum code = {
302 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
303 };
304 struct soc_camera_format_xlate *user_formats;
305
306 while (!v4l2_subdev_call(subdev, pad, enum_mbus_code, NULL, &code)) {
307 raw_fmts++;
308 code.index++;
309 }
310
311 /*
312 * First pass - only count formats this host-sensor
313 * configuration can provide
314 */
315 for (i = 0; i < raw_fmts; i++) {
316 ret = get_formats(v4l2_dev, i, NULL);
317 if (ret < 0)
318 return ERR_PTR(ret);
319 fmts += ret;
320 }
321
322 if (!fmts)
323 return ERR_PTR(-ENXIO);
295ab497 324
283e4a82
RJ
325 user_formats = kcalloc(fmts + 1, sizeof(*user_formats), GFP_KERNEL);
326 if (!user_formats)
327 return ERR_PTR(-ENOMEM);
328
329 /* Second pass - actually fill data formats */
330 fmts = 0;
331 for (i = 0; i < raw_fmts; i++) {
332 ret = get_formats(v4l2_dev, i, user_formats + fmts);
333 if (ret < 0)
334 goto egfmt;
335 fmts += ret;
336 }
337 user_formats[fmts].code = 0;
338
339 return user_formats;
340egfmt:
341 kfree(user_formats);
342 return ERR_PTR(ret);
295ab497
RJ
343}
344
3bc43840
GL
345/*
346 * Videobuf operations
347 */
e009ebd5 348static struct pxa_buffer *vb2_to_pxa_buffer(struct vb2_buffer *vb)
3bc43840 349{
e009ebd5 350 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
3bc43840 351
e009ebd5 352 return container_of(vbuf, struct pxa_buffer, vbuf);
3bc43840
GL
353}
354
e009ebd5 355static struct device *pcdev_to_dev(struct pxa_camera_dev *pcdev)
3bc43840 356{
283e4a82
RJ
357 return pcdev->v4l2_dev.dev;
358}
359
360static struct pxa_camera_dev *v4l2_dev_to_pcdev(struct v4l2_device *v4l2_dev)
361{
362 return container_of(v4l2_dev, struct pxa_camera_dev, v4l2_dev);
37f5aefd
RJ
363}
364
1e77d55a 365static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
e5853918
RJ
366 enum pxa_camera_active_dma act_dma);
367
1e77d55a 368static void pxa_camera_dma_irq_y(void *data)
e5853918
RJ
369{
370 struct pxa_camera_dev *pcdev = data;
371
1e77d55a 372 pxa_camera_dma_irq(pcdev, DMA_Y);
e5853918
RJ
373}
374
1e77d55a 375static void pxa_camera_dma_irq_u(void *data)
e5853918
RJ
376{
377 struct pxa_camera_dev *pcdev = data;
378
1e77d55a 379 pxa_camera_dma_irq(pcdev, DMA_U);
e5853918
RJ
380}
381
1e77d55a 382static void pxa_camera_dma_irq_v(void *data)
e5853918
RJ
383{
384 struct pxa_camera_dev *pcdev = data;
385
1e77d55a 386 pxa_camera_dma_irq(pcdev, DMA_V);
e5853918
RJ
387}
388
37f5aefd
RJ
389/**
390 * pxa_init_dma_channel - init dma descriptors
391 * @pcdev: pxa camera device
e009ebd5 392 * @vb: videobuffer2 buffer
37f5aefd
RJ
393 * @dma: dma video buffer
394 * @channel: dma channel (0 => 'Y', 1 => 'U', 2 => 'V')
395 * @cibr: camera Receive Buffer Register
37f5aefd
RJ
396 *
397 * Prepares the pxa dma descriptors to transfer one camera channel.
37f5aefd 398 *
1e77d55a 399 * Returns 0 if success or -ENOMEM if no memory is available
37f5aefd 400 */
a5462e5b 401static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev,
e009ebd5
RJ
402 struct pxa_buffer *buf, int channel,
403 struct scatterlist *sg, int sglen)
a5462e5b 404{
1e77d55a 405 struct dma_chan *dma_chan = pcdev->dma_chans[channel];
1e77d55a
RJ
406 struct dma_async_tx_descriptor *tx;
407
408 tx = dmaengine_prep_slave_sg(dma_chan, sg, sglen, DMA_DEV_TO_MEM,
409 DMA_PREP_INTERRUPT | DMA_CTRL_REUSE);
410 if (!tx) {
e009ebd5 411 dev_err(pcdev_to_dev(pcdev),
1e77d55a
RJ
412 "dmaengine_prep_slave_sg failed\n");
413 goto fail;
a5462e5b
MR
414 }
415
1e77d55a
RJ
416 tx->callback_param = pcdev;
417 switch (channel) {
418 case 0:
419 tx->callback = pxa_camera_dma_irq_y;
420 break;
421 case 1:
422 tx->callback = pxa_camera_dma_irq_u;
423 break;
424 case 2:
425 tx->callback = pxa_camera_dma_irq_v;
426 break;
37f5aefd
RJ
427 }
428
1e77d55a 429 buf->descs[channel] = tx;
a5462e5b 430 return 0;
1e77d55a 431fail:
e009ebd5
RJ
432 dev_dbg(pcdev_to_dev(pcdev),
433 "%s (vb=%p) dma_tx=%p\n",
434 __func__, buf, tx);
1e77d55a
RJ
435
436 return -ENOMEM;
a5462e5b
MR
437}
438
256b0233
RJ
439static void pxa_videobuf_set_actdma(struct pxa_camera_dev *pcdev,
440 struct pxa_buffer *buf)
441{
442 buf->active_dma = DMA_Y;
283e4a82 443 if (buf->nb_planes == 3)
256b0233
RJ
444 buf->active_dma |= DMA_U | DMA_V;
445}
446
256b0233
RJ
447/**
448 * pxa_dma_start_channels - start DMA channel for active buffer
449 * @pcdev: pxa camera device
450 *
451 * Initialize DMA channels to the beginning of the active video buffer, and
452 * start these channels.
453 */
454static void pxa_dma_start_channels(struct pxa_camera_dev *pcdev)
455{
456 int i;
457 struct pxa_buffer *active;
458
459 active = pcdev->active;
460
461 for (i = 0; i < pcdev->channels; i++) {
e009ebd5 462 dev_dbg(pcdev_to_dev(pcdev),
1e77d55a
RJ
463 "%s (channel=%d)\n", __func__, i);
464 dma_async_issue_pending(pcdev->dma_chans[i]);
256b0233
RJ
465 }
466}
467
468static void pxa_dma_stop_channels(struct pxa_camera_dev *pcdev)
469{
470 int i;
471
472 for (i = 0; i < pcdev->channels; i++) {
e009ebd5 473 dev_dbg(pcdev_to_dev(pcdev),
0166b743 474 "%s (channel=%d)\n", __func__, i);
1e77d55a 475 dmaengine_terminate_all(pcdev->dma_chans[i]);
256b0233
RJ
476 }
477}
478
256b0233
RJ
479static void pxa_dma_add_tail_buf(struct pxa_camera_dev *pcdev,
480 struct pxa_buffer *buf)
481{
482 int i;
256b0233
RJ
483
484 for (i = 0; i < pcdev->channels; i++) {
1e77d55a 485 buf->cookie[i] = dmaengine_submit(buf->descs[i]);
e009ebd5 486 dev_dbg(pcdev_to_dev(pcdev),
1e77d55a
RJ
487 "%s (channel=%d) : submit vb=%p cookie=%d\n",
488 __func__, i, buf, buf->descs[i]->cookie);
ae7410e7 489 }
256b0233
RJ
490}
491
492/**
493 * pxa_camera_start_capture - start video capturing
494 * @pcdev: camera device
495 *
496 * Launch capturing. DMA channels should not be active yet. They should get
497 * activated at the end of frame interrupt, to capture only whole frames, and
498 * never begin the capture of a partial frame.
499 */
500static void pxa_camera_start_capture(struct pxa_camera_dev *pcdev)
501{
a47f6be4 502 unsigned long cicr0;
256b0233 503
e009ebd5 504 dev_dbg(pcdev_to_dev(pcdev), "%s\n", __func__);
e623ebe6 505 __raw_writel(__raw_readl(pcdev->base + CISR), pcdev->base + CISR);
256b0233
RJ
506 /* Enable End-Of-Frame Interrupt */
507 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB;
508 cicr0 &= ~CICR0_EOFM;
509 __raw_writel(cicr0, pcdev->base + CICR0);
510}
511
512static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev)
513{
514 unsigned long cicr0;
515
516 pxa_dma_stop_channels(pcdev);
517
518 cicr0 = __raw_readl(pcdev->base + CICR0) & ~CICR0_ENB;
519 __raw_writel(cicr0, pcdev->base + CICR0);
520
8c62e221 521 pcdev->active = NULL;
e009ebd5 522 dev_dbg(pcdev_to_dev(pcdev), "%s\n", __func__);
3bc43840
GL
523}
524
a5462e5b 525static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
fcdf9bbc
RJ
526 struct pxa_buffer *buf,
527 enum vb2_buffer_state state)
a5462e5b 528{
e009ebd5 529 struct vb2_buffer *vb = &buf->vbuf.vb2_buf;
61634976 530 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
e009ebd5 531
a5462e5b 532 /* _init is used to debug races, see comment in pxa_camera_reqbufs() */
e009ebd5
RJ
533 list_del_init(&buf->queue);
534 vb->timestamp = ktime_get_ns();
61634976
RJ
535 vbuf->sequence = pcdev->buf_sequence++;
536 vbuf->field = V4L2_FIELD_NONE;
e009ebd5
RJ
537 vb2_buffer_done(vb, VB2_BUF_STATE_DONE);
538 dev_dbg(pcdev_to_dev(pcdev), "%s dequeud buffer (buf=0x%p)\n",
539 __func__, buf);
a5462e5b
MR
540
541 if (list_empty(&pcdev->capture)) {
256b0233 542 pxa_camera_stop_capture(pcdev);
a5462e5b
MR
543 return;
544 }
545
546 pcdev->active = list_entry(pcdev->capture.next,
e009ebd5 547 struct pxa_buffer, queue);
a5462e5b
MR
548}
549
256b0233
RJ
550/**
551 * pxa_camera_check_link_miss - check missed DMA linking
552 * @pcdev: camera device
553 *
554 * The DMA chaining is done with DMA running. This means a tiny temporal window
555 * remains, where a buffer is queued on the chain, while the chain is already
25985edc 556 * stopped. This means the tailed buffer would never be transferred by DMA.
256b0233
RJ
557 * This function restarts the capture for this corner case, where :
558 * - DADR() == DADDR_STOP
559 * - a videobuffer is queued on the pcdev->capture list
560 *
561 * Please check the "DMA hot chaining timeslice issue" in
562 * Documentation/video4linux/pxa_camera.txt
563 *
564 * Context: should only be called within the dma irq handler
565 */
1e77d55a
RJ
566static void pxa_camera_check_link_miss(struct pxa_camera_dev *pcdev,
567 dma_cookie_t last_submitted,
568 dma_cookie_t last_issued)
256b0233 569{
1e77d55a 570 bool is_dma_stopped = last_submitted != last_issued;
256b0233 571
e009ebd5 572 dev_dbg(pcdev_to_dev(pcdev),
1e77d55a 573 "%s : top queued buffer=%p, is_dma_stopped=%d\n",
256b0233 574 __func__, pcdev->active, is_dma_stopped);
1e77d55a 575
256b0233
RJ
576 if (pcdev->active && is_dma_stopped)
577 pxa_camera_start_capture(pcdev);
578}
579
1e77d55a 580static void pxa_camera_dma_irq(struct pxa_camera_dev *pcdev,
a5462e5b 581 enum pxa_camera_active_dma act_dma)
3bc43840 582{
1e77d55a 583 struct pxa_buffer *buf, *last_buf;
3bc43840 584 unsigned long flags;
1e77d55a
RJ
585 u32 camera_status, overrun;
586 int chan;
1e77d55a
RJ
587 enum dma_status last_status;
588 dma_cookie_t last_issued;
3bc43840
GL
589
590 spin_lock_irqsave(&pcdev->lock, flags);
591
256b0233 592 camera_status = __raw_readl(pcdev->base + CISR);
295ab497 593 dev_dbg(pcdev_to_dev(pcdev), "camera dma irq, cisr=0x%x dma=%d\n",
1e77d55a 594 camera_status, act_dma);
256b0233
RJ
595 overrun = CISR_IFO_0;
596 if (pcdev->channels == 3)
597 overrun |= CISR_IFO_1 | CISR_IFO_2;
7102b773 598
8c62e221
RJ
599 /*
600 * pcdev->active should not be NULL in DMA irq handler.
601 *
602 * But there is one corner case : if capture was stopped due to an
603 * overrun of channel 1, and at that same channel 2 was completed.
604 *
605 * When handling the overrun in DMA irq for channel 1, we'll stop the
606 * capture and restart it (and thus set pcdev->active to NULL). But the
607 * DMA irq handler will already be pending for channel 2. So on entering
608 * the DMA irq handler for channel 2 there will be no active buffer, yet
609 * that is normal.
610 */
611 if (!pcdev->active)
3bc43840 612 goto out;
3bc43840 613
e009ebd5
RJ
614 buf = pcdev->active;
615 WARN_ON(buf->inwork || list_empty(&buf->queue));
3bc43840 616
1e77d55a
RJ
617 /*
618 * It's normal if the last frame creates an overrun, as there
619 * are no more DMA descriptors to fetch from QCI fifos
620 */
621 switch (act_dma) {
622 case DMA_U:
623 chan = 1;
624 break;
625 case DMA_V:
626 chan = 2;
627 break;
628 default:
629 chan = 0;
630 break;
631 }
632 last_buf = list_entry(pcdev->capture.prev,
e009ebd5 633 struct pxa_buffer, queue);
1e77d55a
RJ
634 last_status = dma_async_is_tx_complete(pcdev->dma_chans[chan],
635 last_buf->cookie[chan],
636 NULL, &last_issued);
637 if (camera_status & overrun &&
638 last_status != DMA_COMPLETE) {
295ab497 639 dev_dbg(pcdev_to_dev(pcdev), "FIFO overrun! CISR: %x\n",
1e77d55a
RJ
640 camera_status);
641 pxa_camera_stop_capture(pcdev);
e009ebd5 642 list_for_each_entry(buf, &pcdev->capture, queue)
1e77d55a
RJ
643 pxa_dma_add_tail_buf(pcdev, buf);
644 pxa_camera_start_capture(pcdev);
645 goto out;
646 }
647 buf->active_dma &= ~act_dma;
648 if (!buf->active_dma) {
fcdf9bbc 649 pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_DONE);
1e77d55a
RJ
650 pxa_camera_check_link_miss(pcdev, last_buf->cookie[chan],
651 last_issued);
256b0233 652 }
3bc43840
GL
653
654out:
655 spin_unlock_irqrestore(&pcdev->lock, flags);
656}
657
40e2e092
GL
658static u32 mclk_get_divisor(struct platform_device *pdev,
659 struct pxa_camera_dev *pcdev)
3bc43840 660{
cf34cba7
GL
661 unsigned long mclk = pcdev->mclk;
662 u32 div;
3bc43840
GL
663 unsigned long lcdclk;
664
cf34cba7
GL
665 lcdclk = clk_get_rate(pcdev->clk);
666 pcdev->ciclk = lcdclk;
3bc43840 667
cf34cba7
GL
668 /* mclk <= ciclk / 4 (27.4.2) */
669 if (mclk > lcdclk / 4) {
670 mclk = lcdclk / 4;
295ab497
RJ
671 dev_warn(pcdev_to_dev(pcdev),
672 "Limiting master clock to %lu\n", mclk);
cf34cba7
GL
673 }
674
675 /* We verify mclk != 0, so if anyone breaks it, here comes their Oops */
676 div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1;
3bc43840 677
cf34cba7
GL
678 /* If we're not supplying MCLK, leave it at 0 */
679 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
680 pcdev->mclk = lcdclk / (2 * (div + 1));
3bc43840 681
295ab497 682 dev_dbg(pcdev_to_dev(pcdev), "LCD clock %luHz, target freq %luHz, divisor %u\n",
40e2e092 683 lcdclk, mclk, div);
3bc43840
GL
684
685 return div;
686}
687
cf34cba7
GL
688static void recalculate_fifo_timeout(struct pxa_camera_dev *pcdev,
689 unsigned long pclk)
690{
691 /* We want a timeout > 1 pixel time, not ">=" */
692 u32 ciclk_per_pixel = pcdev->ciclk / pclk + 1;
693
694 __raw_writel(ciclk_per_pixel, pcdev->base + CITOR);
695}
696
7102b773 697static void pxa_camera_activate(struct pxa_camera_dev *pcdev)
3bc43840 698{
3bc43840
GL
699 u32 cicr4 = 0;
700
5ca11fa3
EM
701 /* disable all interrupts */
702 __raw_writel(0x3ff, pcdev->base + CICR0);
3bc43840
GL
703
704 if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
705 cicr4 |= CICR4_PCLK_EN;
706 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
707 cicr4 |= CICR4_MCLK_EN;
708 if (pcdev->platform_flags & PXA_CAMERA_PCP)
709 cicr4 |= CICR4_PCP;
710 if (pcdev->platform_flags & PXA_CAMERA_HSP)
711 cicr4 |= CICR4_HSP;
712 if (pcdev->platform_flags & PXA_CAMERA_VSP)
713 cicr4 |= CICR4_VSP;
714
cf34cba7
GL
715 __raw_writel(pcdev->mclk_divisor | cicr4, pcdev->base + CICR4);
716
717 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
718 /* Initialise the timeout under the assumption pclk = mclk */
719 recalculate_fifo_timeout(pcdev, pcdev->mclk);
720 else
721 /* "Safe default" - 13MHz */
722 recalculate_fifo_timeout(pcdev, 13000000);
3bc43840 723
91acd962 724 clk_prepare_enable(pcdev->clk);
3bc43840
GL
725}
726
7102b773 727static void pxa_camera_deactivate(struct pxa_camera_dev *pcdev)
3bc43840 728{
91acd962 729 clk_disable_unprepare(pcdev->clk);
3bc43840
GL
730}
731
e623ebe6 732static void pxa_camera_eof(unsigned long arg)
3bc43840 733{
e623ebe6
RJ
734 struct pxa_camera_dev *pcdev = (struct pxa_camera_dev *)arg;
735 unsigned long cifr;
256b0233 736 struct pxa_buffer *buf;
3bc43840 737
e009ebd5 738 dev_dbg(pcdev_to_dev(pcdev),
e623ebe6
RJ
739 "Camera interrupt status 0x%x\n",
740 __raw_readl(pcdev->base + CISR));
741
742 /* Reset the FIFOs */
743 cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
744 __raw_writel(cifr, pcdev->base + CIFR);
745
746 pcdev->active = list_first_entry(&pcdev->capture,
e009ebd5
RJ
747 struct pxa_buffer, queue);
748 buf = pcdev->active;
e623ebe6
RJ
749 pxa_videobuf_set_actdma(pcdev, buf);
750
751 pxa_dma_start_channels(pcdev);
752}
753
754static irqreturn_t pxa_camera_irq(int irq, void *data)
755{
756 struct pxa_camera_dev *pcdev = data;
757 unsigned long status, cicr0;
758
5ca11fa3 759 status = __raw_readl(pcdev->base + CISR);
e009ebd5 760 dev_dbg(pcdev_to_dev(pcdev),
0166b743 761 "Camera interrupt status 0x%lx\n", status);
3bc43840 762
e7c50688
GL
763 if (!status)
764 return IRQ_NONE;
765
5ca11fa3 766 __raw_writel(status, pcdev->base + CISR);
e7c50688
GL
767
768 if (status & CISR_EOF) {
5ca11fa3
EM
769 cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_EOFM;
770 __raw_writel(cicr0, pcdev->base + CICR0);
e623ebe6 771 tasklet_schedule(&pcdev->task_eof);
e7c50688
GL
772 }
773
3bc43840
GL
774 return IRQ_HANDLED;
775}
776
ad5f2e85
GL
777static int test_platform_param(struct pxa_camera_dev *pcdev,
778 unsigned char buswidth, unsigned long *flags)
3bc43840 779{
ad5f2e85
GL
780 /*
781 * Platform specified synchronization and pixel clock polarities are
782 * only a recommendation and are only used during probing. The PXA270
783 * quick capture interface supports both.
784 */
785 *flags = (pcdev->platform_flags & PXA_CAMERA_MASTER ?
679419aa
GL
786 V4L2_MBUS_MASTER : V4L2_MBUS_SLAVE) |
787 V4L2_MBUS_HSYNC_ACTIVE_HIGH |
788 V4L2_MBUS_HSYNC_ACTIVE_LOW |
789 V4L2_MBUS_VSYNC_ACTIVE_HIGH |
790 V4L2_MBUS_VSYNC_ACTIVE_LOW |
791 V4L2_MBUS_DATA_ACTIVE_HIGH |
792 V4L2_MBUS_PCLK_SAMPLE_RISING |
793 V4L2_MBUS_PCLK_SAMPLE_FALLING;
3bc43840
GL
794
795 /* If requested data width is supported by the platform, use it */
679419aa
GL
796 if ((1 << (buswidth - 1)) & pcdev->width_flags)
797 return 0;
ad5f2e85 798
679419aa 799 return -EINVAL;
ad5f2e85
GL
800}
801
283e4a82 802static void pxa_camera_setup_cicr(struct pxa_camera_dev *pcdev,
6a6c8786 803 unsigned long flags, __u32 pixfmt)
ad5f2e85 804{
6a6c8786 805 unsigned long dw, bpp;
32536108 806 u32 cicr0, cicr1, cicr2, cicr3, cicr4 = 0, y_skip_top;
b36bcbd6 807 int ret = sensor_call(pcdev, sensor, g_skip_top_lines, &y_skip_top);
32536108
GL
808
809 if (ret < 0)
810 y_skip_top = 0;
3bc43840 811
5d28d525
GL
812 /*
813 * Datawidth is now guaranteed to be equal to one of the three values.
814 * We fix bit-per-pixel equal to data-width...
815 */
283e4a82 816 switch (pcdev->current_fmt->host_fmt->bits_per_sample) {
679419aa 817 case 10:
3bc43840
GL
818 dw = 4;
819 bpp = 0x40;
820 break;
679419aa 821 case 9:
3bc43840
GL
822 dw = 3;
823 bpp = 0x20;
824 break;
825 default:
5d28d525
GL
826 /*
827 * Actually it can only be 8 now,
828 * default is just to silence compiler warnings
829 */
679419aa 830 case 8:
3bc43840
GL
831 dw = 2;
832 bpp = 0;
833 }
834
835 if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
836 cicr4 |= CICR4_PCLK_EN;
837 if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
838 cicr4 |= CICR4_MCLK_EN;
679419aa 839 if (flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
3bc43840 840 cicr4 |= CICR4_PCP;
679419aa 841 if (flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
3bc43840 842 cicr4 |= CICR4_HSP;
679419aa 843 if (flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
3bc43840
GL
844 cicr4 |= CICR4_VSP;
845
5ca11fa3 846 cicr0 = __raw_readl(pcdev->base + CICR0);
3bc43840 847 if (cicr0 & CICR0_ENB)
5ca11fa3 848 __raw_writel(cicr0 & ~CICR0_ENB, pcdev->base + CICR0);
a5462e5b 849
283e4a82 850 cicr1 = CICR1_PPL_VAL(pcdev->current_pix.width - 1) | bpp | dw;
a5462e5b
MR
851
852 switch (pixfmt) {
853 case V4L2_PIX_FMT_YUV422P:
e7c50688 854 pcdev->channels = 3;
a5462e5b 855 cicr1 |= CICR1_YCBCR_F;
2a48fc73
RJ
856 /*
857 * Normally, pxa bus wants as input UYVY format. We allow all
858 * reorderings of the YUV422 format, as no processing is done,
859 * and the YUV stream is just passed through without any
860 * transformation. Note that UYVY is the only format that
861 * should be used if pxa framebuffer Overlay2 is used.
862 */
863 case V4L2_PIX_FMT_UYVY:
864 case V4L2_PIX_FMT_VYUY:
a5462e5b 865 case V4L2_PIX_FMT_YUYV:
2a48fc73 866 case V4L2_PIX_FMT_YVYU:
a5462e5b
MR
867 cicr1 |= CICR1_COLOR_SP_VAL(2);
868 break;
869 case V4L2_PIX_FMT_RGB555:
870 cicr1 |= CICR1_RGB_BPP_VAL(1) | CICR1_RGBT_CONV_VAL(2) |
871 CICR1_TBIT | CICR1_COLOR_SP_VAL(1);
872 break;
873 case V4L2_PIX_FMT_RGB565:
874 cicr1 |= CICR1_COLOR_SP_VAL(1) | CICR1_RGB_BPP_VAL(2);
875 break;
876 }
877
5ca11fa3 878 cicr2 = 0;
283e4a82 879 cicr3 = CICR3_LPF_VAL(pcdev->current_pix.height - 1) |
32536108 880 CICR3_BFW_VAL(min((u32)255, y_skip_top));
cf34cba7 881 cicr4 |= pcdev->mclk_divisor;
5ca11fa3
EM
882
883 __raw_writel(cicr1, pcdev->base + CICR1);
884 __raw_writel(cicr2, pcdev->base + CICR2);
885 __raw_writel(cicr3, pcdev->base + CICR3);
886 __raw_writel(cicr4, pcdev->base + CICR4);
3bc43840
GL
887
888 /* CIF interrupts are not used, only DMA */
5ca11fa3
EM
889 cicr0 = (cicr0 & CICR0_ENB) | (pcdev->platform_flags & PXA_CAMERA_MASTER ?
890 CICR0_SIM_MP : (CICR0_SL_CAP_EN | CICR0_SIM_SP));
891 cicr0 |= CICR0_DMAEN | CICR0_IRQ_MASK;
892 __raw_writel(cicr0, pcdev->base + CICR0);
6a6c8786
GL
893}
894
6f28435d
RJ
895/*
896 * Videobuf2 section
897 */
898static void pxa_buffer_cleanup(struct pxa_buffer *buf)
899{
900 int i;
901
902 for (i = 0; i < 3 && buf->descs[i]; i++) {
903 dmaengine_desc_free(buf->descs[i]);
904 kfree(buf->sg[i]);
905 buf->descs[i] = NULL;
906 buf->sg[i] = NULL;
907 buf->sg_len[i] = 0;
908 buf->plane_sizes[i] = 0;
909 }
910 buf->nb_planes = 0;
911}
912
913static int pxa_buffer_init(struct pxa_camera_dev *pcdev,
914 struct pxa_buffer *buf)
915{
916 struct vb2_buffer *vb = &buf->vbuf.vb2_buf;
917 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
918 int nb_channels = pcdev->channels;
919 int i, ret = 0;
920 unsigned long size = vb2_plane_size(vb, 0);
921
922 switch (nb_channels) {
923 case 1:
924 buf->plane_sizes[0] = size;
925 break;
926 case 3:
927 buf->plane_sizes[0] = size / 2;
928 buf->plane_sizes[1] = size / 4;
929 buf->plane_sizes[2] = size / 4;
930 break;
931 default:
932 return -EINVAL;
933 };
934 buf->nb_planes = nb_channels;
935
936 ret = sg_split(sgt->sgl, sgt->nents, 0, nb_channels,
937 buf->plane_sizes, buf->sg, buf->sg_len, GFP_KERNEL);
938 if (ret < 0) {
939 dev_err(pcdev_to_dev(pcdev),
940 "sg_split failed: %d\n", ret);
941 return ret;
942 }
943 for (i = 0; i < nb_channels; i++) {
944 ret = pxa_init_dma_channel(pcdev, buf, i,
945 buf->sg[i], buf->sg_len[i]);
946 if (ret) {
947 pxa_buffer_cleanup(buf);
948 return ret;
949 }
950 }
951 INIT_LIST_HEAD(&buf->queue);
952
953 return ret;
954}
955
956static void pxac_vb2_cleanup(struct vb2_buffer *vb)
957{
958 struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
959 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
960
961 dev_dbg(pcdev_to_dev(pcdev),
962 "%s(vb=%p)\n", __func__, vb);
963 pxa_buffer_cleanup(buf);
964}
965
966static void pxac_vb2_queue(struct vb2_buffer *vb)
967{
968 struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
969 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
970
971 dev_dbg(pcdev_to_dev(pcdev),
972 "%s(vb=%p) nb_channels=%d size=%lu active=%p\n",
973 __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0),
974 pcdev->active);
975
976 list_add_tail(&buf->queue, &pcdev->capture);
977
978 pxa_dma_add_tail_buf(pcdev, buf);
979}
980
981/*
982 * Please check the DMA prepared buffer structure in :
983 * Documentation/video4linux/pxa_camera.txt
984 * Please check also in pxa_camera_check_link_miss() to understand why DMA chain
985 * modification while DMA chain is running will work anyway.
986 */
987static int pxac_vb2_prepare(struct vb2_buffer *vb)
988{
989 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
990 struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
6f28435d
RJ
991 int ret = 0;
992
993 switch (pcdev->channels) {
994 case 1:
995 case 3:
283e4a82 996 vb2_set_plane_payload(vb, 0, pcdev->current_pix.sizeimage);
6f28435d
RJ
997 break;
998 default:
999 return -EINVAL;
1000 }
1001
1002 dev_dbg(pcdev_to_dev(pcdev),
1003 "%s (vb=%p) nb_channels=%d size=%lu\n",
1004 __func__, vb, pcdev->channels, vb2_get_plane_payload(vb, 0));
1005
283e4a82 1006 WARN_ON(!pcdev->current_fmt);
6f28435d
RJ
1007
1008#ifdef DEBUG
1009 /*
1010 * This can be useful if you want to see if we actually fill
1011 * the buffer with something
1012 */
1013 for (i = 0; i < vb->num_planes; i++)
1014 memset((void *)vb2_plane_vaddr(vb, i),
1015 0xaa, vb2_get_plane_payload(vb, i));
1016#endif
1017
1018 /*
1019 * I think, in buf_prepare you only have to protect global data,
1020 * the actual buffer is yours
1021 */
1022 buf->inwork = 0;
1023 pxa_videobuf_set_actdma(pcdev, buf);
1024
1025 return ret;
1026}
1027
1028static int pxac_vb2_init(struct vb2_buffer *vb)
1029{
1030 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue);
1031 struct pxa_buffer *buf = vb2_to_pxa_buffer(vb);
1032
1033 dev_dbg(pcdev_to_dev(pcdev),
1034 "%s(nb_channels=%d)\n",
1035 __func__, pcdev->channels);
1036
1037 return pxa_buffer_init(pcdev, buf);
1038}
1039
1040static int pxac_vb2_queue_setup(struct vb2_queue *vq,
1041 unsigned int *nbufs,
1042 unsigned int *num_planes, unsigned int sizes[],
1043 struct device *alloc_devs[])
1044{
1045 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
283e4a82 1046 int size = pcdev->current_pix.sizeimage;
6f28435d
RJ
1047
1048 dev_dbg(pcdev_to_dev(pcdev),
1049 "%s(vq=%p nbufs=%d num_planes=%d size=%d)\n",
1050 __func__, vq, *nbufs, *num_planes, size);
1051 /*
1052 * Called from VIDIOC_REQBUFS or in compatibility mode For YUV422P
1053 * format, even if there are 3 planes Y, U and V, we reply there is only
1054 * one plane, containing Y, U and V data, one after the other.
1055 */
1056 if (*num_planes)
1057 return sizes[0] < size ? -EINVAL : 0;
1058
1059 *num_planes = 1;
1060 switch (pcdev->channels) {
1061 case 1:
1062 case 3:
1063 sizes[0] = size;
1064 break;
1065 default:
1066 return -EINVAL;
1067 }
1068
1069 if (!*nbufs)
1070 *nbufs = 1;
1071
1072 return 0;
1073}
1074
1075static int pxac_vb2_start_streaming(struct vb2_queue *vq, unsigned int count)
1076{
1077 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
1078
1079 dev_dbg(pcdev_to_dev(pcdev), "%s(count=%d) active=%p\n",
1080 __func__, count, pcdev->active);
1081
61634976 1082 pcdev->buf_sequence = 0;
6f28435d
RJ
1083 if (!pcdev->active)
1084 pxa_camera_start_capture(pcdev);
1085
1086 return 0;
1087}
1088
1089static void pxac_vb2_stop_streaming(struct vb2_queue *vq)
1090{
fcdf9bbc
RJ
1091 struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vq);
1092 struct pxa_buffer *buf, *tmp;
1093
1094 dev_dbg(pcdev_to_dev(pcdev), "%s active=%p\n",
1095 __func__, pcdev->active);
1096 pxa_camera_stop_capture(pcdev);
1097
1098 list_for_each_entry_safe(buf, tmp, &pcdev->capture, queue)
1099 pxa_camera_wakeup(pcdev, buf, VB2_BUF_STATE_ERROR);
6f28435d
RJ
1100}
1101
1102static struct vb2_ops pxac_vb2_ops = {
1103 .queue_setup = pxac_vb2_queue_setup,
1104 .buf_init = pxac_vb2_init,
1105 .buf_prepare = pxac_vb2_prepare,
1106 .buf_queue = pxac_vb2_queue,
1107 .buf_cleanup = pxac_vb2_cleanup,
1108 .start_streaming = pxac_vb2_start_streaming,
1109 .stop_streaming = pxac_vb2_stop_streaming,
1110 .wait_prepare = vb2_ops_wait_prepare,
1111 .wait_finish = vb2_ops_wait_finish,
1112};
1113
283e4a82 1114static int pxa_camera_init_videobuf2(struct pxa_camera_dev *pcdev)
6f28435d 1115{
6f28435d 1116 int ret;
283e4a82 1117 struct vb2_queue *vq = &pcdev->vb2_vq;
6f28435d 1118
283e4a82 1119 memset(vq, 0, sizeof(*vq));
6f28435d
RJ
1120 vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1121 vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
1122 vq->drv_priv = pcdev;
1123 vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1124 vq->buf_struct_size = sizeof(struct pxa_buffer);
283e4a82 1125 vq->dev = pcdev->v4l2_dev.dev;
6f28435d
RJ
1126
1127 vq->ops = &pxac_vb2_ops;
1128 vq->mem_ops = &vb2_dma_sg_memops;
283e4a82 1129 vq->lock = &pcdev->mlock;
6f28435d
RJ
1130
1131 ret = vb2_queue_init(vq);
1132 dev_dbg(pcdev_to_dev(pcdev),
1133 "vb2_queue_init(vq=%p): %d\n", vq, ret);
1134
1135 return ret;
1136}
1137
1138/*
1139 * Video ioctls section
1140 */
283e4a82 1141static int pxa_camera_set_bus_param(struct pxa_camera_dev *pcdev)
6a6c8786 1142{
679419aa 1143 struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,};
283e4a82 1144 u32 pixfmt = pcdev->current_fmt->host_fmt->fourcc;
679419aa 1145 unsigned long bus_flags, common_flags;
760697be 1146 int ret;
6a6c8786 1147
283e4a82
RJ
1148 ret = test_platform_param(pcdev,
1149 pcdev->current_fmt->host_fmt->bits_per_sample,
d2dcad49 1150 &bus_flags);
6a6c8786
GL
1151 if (ret < 0)
1152 return ret;
1153
b36bcbd6 1154 ret = sensor_call(pcdev, video, g_mbus_config, &cfg);
679419aa
GL
1155 if (!ret) {
1156 common_flags = soc_mbus_config_compatible(&cfg,
1157 bus_flags);
1158 if (!common_flags) {
295ab497 1159 dev_warn(pcdev_to_dev(pcdev),
679419aa
GL
1160 "Flags incompatible: camera 0x%x, host 0x%lx\n",
1161 cfg.flags, bus_flags);
1162 return -EINVAL;
1163 }
1164 } else if (ret != -ENOIOCTLCMD) {
1165 return ret;
1166 } else {
1167 common_flags = bus_flags;
1168 }
6a6c8786
GL
1169
1170 pcdev->channels = 1;
1171
1172 /* Make choises, based on platform preferences */
679419aa
GL
1173 if ((common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) &&
1174 (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
6a6c8786 1175 if (pcdev->platform_flags & PXA_CAMERA_HSP)
679419aa 1176 common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
6a6c8786 1177 else
679419aa 1178 common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
6a6c8786
GL
1179 }
1180
679419aa
GL
1181 if ((common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) &&
1182 (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
6a6c8786 1183 if (pcdev->platform_flags & PXA_CAMERA_VSP)
679419aa 1184 common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
6a6c8786 1185 else
679419aa 1186 common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
6a6c8786
GL
1187 }
1188
679419aa
GL
1189 if ((common_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) &&
1190 (common_flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)) {
6a6c8786 1191 if (pcdev->platform_flags & PXA_CAMERA_PCP)
679419aa 1192 common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_RISING;
6a6c8786 1193 else
679419aa 1194 common_flags &= ~V4L2_MBUS_PCLK_SAMPLE_FALLING;
6a6c8786
GL
1195 }
1196
679419aa 1197 cfg.flags = common_flags;
b36bcbd6 1198 ret = sensor_call(pcdev, video, s_mbus_config, &cfg);
679419aa 1199 if (ret < 0 && ret != -ENOIOCTLCMD) {
283e4a82
RJ
1200 dev_dbg(pcdev_to_dev(pcdev),
1201 "camera s_mbus_config(0x%lx) returned %d\n",
679419aa 1202 common_flags, ret);
6a6c8786 1203 return ret;
679419aa
GL
1204 }
1205
283e4a82 1206 pxa_camera_setup_cicr(pcdev, common_flags, pixfmt);
3bc43840
GL
1207
1208 return 0;
1209}
1210
283e4a82 1211static int pxa_camera_try_bus_param(struct pxa_camera_dev *pcdev,
2a48fc73 1212 unsigned char buswidth)
ad5f2e85 1213{
679419aa
GL
1214 struct v4l2_mbus_config cfg = {.type = V4L2_MBUS_PARALLEL,};
1215 unsigned long bus_flags, common_flags;
2a48fc73 1216 int ret = test_platform_param(pcdev, buswidth, &bus_flags);
ad5f2e85
GL
1217
1218 if (ret < 0)
1219 return ret;
1220
b36bcbd6 1221 ret = sensor_call(pcdev, video, g_mbus_config, &cfg);
679419aa
GL
1222 if (!ret) {
1223 common_flags = soc_mbus_config_compatible(&cfg,
1224 bus_flags);
1225 if (!common_flags) {
295ab497 1226 dev_warn(pcdev_to_dev(pcdev),
679419aa
GL
1227 "Flags incompatible: camera 0x%x, host 0x%lx\n",
1228 cfg.flags, bus_flags);
1229 return -EINVAL;
1230 }
1231 } else if (ret == -ENOIOCTLCMD) {
1232 ret = 0;
1233 }
ad5f2e85 1234
679419aa 1235 return ret;
ad5f2e85
GL
1236}
1237
760697be 1238static const struct soc_mbus_pixelfmt pxa_camera_formats[] = {
2a48fc73 1239 {
760697be
GL
1240 .fourcc = V4L2_PIX_FMT_YUV422P,
1241 .name = "Planar YUV422 16 bit",
1242 .bits_per_sample = 8,
1243 .packing = SOC_MBUS_PACKING_2X8_PADHI,
1244 .order = SOC_MBUS_ORDER_LE,
ad3b81fa 1245 .layout = SOC_MBUS_LAYOUT_PLANAR_2Y_U_V,
2a48fc73
RJ
1246 },
1247};
1248
760697be
GL
1249/* This will be corrected as we get more formats */
1250static bool pxa_camera_packing_supported(const struct soc_mbus_pixelfmt *fmt)
ad5f2e85 1251{
760697be
GL
1252 return fmt->packing == SOC_MBUS_PACKING_NONE ||
1253 (fmt->bits_per_sample == 8 &&
1254 fmt->packing == SOC_MBUS_PACKING_2X8_PADHI) ||
1255 (fmt->bits_per_sample > 8 &&
1256 fmt->packing == SOC_MBUS_PACKING_EXTEND16);
2a48fc73
RJ
1257}
1258
283e4a82
RJ
1259static int pxa_camera_get_formats(struct v4l2_device *v4l2_dev,
1260 unsigned int idx,
2a48fc73
RJ
1261 struct soc_camera_format_xlate *xlate)
1262{
283e4a82 1263 struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(v4l2_dev);
760697be 1264 int formats = 0, ret;
ebcff5fc
HV
1265 struct v4l2_subdev_mbus_code_enum code = {
1266 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
1267 .index = idx,
1268 };
760697be 1269 const struct soc_mbus_pixelfmt *fmt;
2a48fc73 1270
b36bcbd6 1271 ret = sensor_call(pcdev, pad, enum_mbus_code, NULL, &code);
760697be
GL
1272 if (ret < 0)
1273 /* No more formats */
1274 return 0;
2a48fc73 1275
ebcff5fc 1276 fmt = soc_mbus_get_fmtdesc(code.code);
760697be 1277 if (!fmt) {
283e4a82
RJ
1278 dev_err(pcdev_to_dev(pcdev),
1279 "Invalid format code #%u: %d\n", idx, code.code);
2a48fc73 1280 return 0;
760697be 1281 }
3bc43840 1282
760697be 1283 /* This also checks support for the requested bits-per-sample */
283e4a82 1284 ret = pxa_camera_try_bus_param(pcdev, fmt->bits_per_sample);
2a48fc73
RJ
1285 if (ret < 0)
1286 return 0;
1287
ebcff5fc 1288 switch (code.code) {
27ffaeb0 1289 case MEDIA_BUS_FMT_UYVY8_2X8:
2a48fc73
RJ
1290 formats++;
1291 if (xlate) {
760697be 1292 xlate->host_fmt = &pxa_camera_formats[0];
ebcff5fc 1293 xlate->code = code.code;
2a48fc73 1294 xlate++;
295ab497
RJ
1295 dev_dbg(pcdev_to_dev(pcdev),
1296 "Providing format %s using code %d\n",
ebcff5fc 1297 pxa_camera_formats[0].name, code.code);
2a48fc73 1298 }
855f5aa4 1299 /* fall through */
27ffaeb0
BB
1300 case MEDIA_BUS_FMT_VYUY8_2X8:
1301 case MEDIA_BUS_FMT_YUYV8_2X8:
1302 case MEDIA_BUS_FMT_YVYU8_2X8:
1303 case MEDIA_BUS_FMT_RGB565_2X8_LE:
1304 case MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE:
760697be 1305 if (xlate)
295ab497
RJ
1306 dev_dbg(pcdev_to_dev(pcdev),
1307 "Providing format %s packed\n",
760697be 1308 fmt->name);
2a48fc73
RJ
1309 break;
1310 default:
760697be
GL
1311 if (!pxa_camera_packing_supported(fmt))
1312 return 0;
1313 if (xlate)
295ab497 1314 dev_dbg(pcdev_to_dev(pcdev),
2a48fc73 1315 "Providing format %s in pass-through mode\n",
760697be 1316 fmt->name);
855f5aa4 1317 break;
760697be
GL
1318 }
1319
1320 /* Generic pass-through */
1321 formats++;
1322 if (xlate) {
1323 xlate->host_fmt = fmt;
ebcff5fc 1324 xlate->code = code.code;
760697be 1325 xlate++;
2a48fc73
RJ
1326 }
1327
1328 return formats;
1329}
1330
283e4a82
RJ
1331static int pxa_camera_build_formats(struct pxa_camera_dev *pcdev)
1332{
1333 struct soc_camera_format_xlate *xlate;
1334
1335 xlate = soc_mbus_build_fmts_xlate(&pcdev->v4l2_dev, pcdev->sensor,
1336 pxa_camera_get_formats);
1337 if (IS_ERR(xlate))
1338 return PTR_ERR(xlate);
1339
1340 pcdev->user_formats = xlate;
1341 return 0;
1342}
1343
1344static void pxa_camera_destroy_formats(struct pxa_camera_dev *pcdev)
6a6c8786 1345{
283e4a82 1346 kfree(pcdev->user_formats);
6a6c8786
GL
1347}
1348
760697be 1349static int pxa_camera_check_frame(u32 width, u32 height)
6a6c8786
GL
1350{
1351 /* limit to pxa hardware capabilities */
760697be
GL
1352 return height < 32 || height > 2048 || width < 48 || width > 2048 ||
1353 (width & 0x01);
6a6c8786
GL
1354}
1355
cdd657eb
RJ
1356#ifdef CONFIG_VIDEO_ADV_DEBUG
1357static int pxac_vidioc_g_register(struct file *file, void *priv,
1358 struct v4l2_dbg_register *reg)
1359{
1360 struct pxa_camera_dev *pcdev = video_drvdata(file);
1361
1362 if (reg->reg > CIBR2)
1363 return -ERANGE;
1364
1365 reg->val = __raw_readl(pcdev->base + reg->reg);
1366 reg->size = sizeof(__u32);
1367 return 0;
1368}
1369
1370static int pxac_vidioc_s_register(struct file *file, void *priv,
1371 const struct v4l2_dbg_register *reg)
1372{
1373 struct pxa_camera_dev *pcdev = video_drvdata(file);
1374
1375 if (reg->reg > CIBR2)
1376 return -ERANGE;
1377 if (reg->size != sizeof(__u32))
1378 return -EINVAL;
1379 __raw_writel(reg->val, pcdev->base + reg->reg);
1380 return 0;
1381}
1382#endif
1383
283e4a82
RJ
1384static int pxac_vidioc_enum_fmt_vid_cap(struct file *filp, void *priv,
1385 struct v4l2_fmtdesc *f)
ad5f2e85 1386{
283e4a82
RJ
1387 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1388 const struct soc_mbus_pixelfmt *format;
1389 unsigned int idx;
760697be 1390
283e4a82
RJ
1391 for (idx = 0; pcdev->user_formats[idx].code; idx++);
1392 if (f->index >= idx)
760697be 1393 return -EINVAL;
2a48fc73 1394
283e4a82
RJ
1395 format = pcdev->user_formats[f->index].host_fmt;
1396 f->pixelformat = format->fourcc;
1397 return 0;
1398}
760697be 1399
283e4a82
RJ
1400static int pxac_vidioc_g_fmt_vid_cap(struct file *filp, void *priv,
1401 struct v4l2_format *f)
1402{
1403 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1404 struct v4l2_pix_format *pix = &f->fmt.pix;
25c4d74e 1405
283e4a82
RJ
1406 pix->width = pcdev->current_pix.width;
1407 pix->height = pcdev->current_pix.height;
1408 pix->bytesperline = pcdev->current_pix.bytesperline;
1409 pix->sizeimage = pcdev->current_pix.sizeimage;
1410 pix->field = pcdev->current_pix.field;
1411 pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc;
1412 pix->colorspace = pcdev->current_pix.colorspace;
1413 dev_dbg(pcdev_to_dev(pcdev), "current_fmt->fourcc: 0x%08x\n",
1414 pcdev->current_fmt->host_fmt->fourcc);
1415 return 0;
ad5f2e85
GL
1416}
1417
283e4a82
RJ
1418static int pxac_vidioc_try_fmt_vid_cap(struct file *filp, void *priv,
1419 struct v4l2_format *f)
3bc43840 1420{
283e4a82 1421 struct pxa_camera_dev *pcdev = video_drvdata(filp);
2a48fc73
RJ
1422 const struct soc_camera_format_xlate *xlate;
1423 struct v4l2_pix_format *pix = &f->fmt.pix;
5eab4983
HV
1424 struct v4l2_subdev_pad_config pad_cfg;
1425 struct v4l2_subdev_format format = {
1426 .which = V4L2_SUBDEV_FORMAT_TRY,
1427 };
1428 struct v4l2_mbus_framefmt *mf = &format.format;
2a48fc73 1429 __u32 pixfmt = pix->pixelformat;
bf507158 1430 int ret;
a2c8c68c 1431
283e4a82 1432 xlate = soc_mbus_xlate_by_fourcc(pcdev->user_formats, pixfmt);
2a48fc73 1433 if (!xlate) {
295ab497 1434 dev_warn(pcdev_to_dev(pcdev), "Format %x not found\n", pixfmt);
25c4d74e 1435 return -EINVAL;
2a48fc73 1436 }
25c4d74e 1437
92a8337b 1438 /*
4a6b8df2
TP
1439 * Limit to pxa hardware capabilities. YUV422P planar format requires
1440 * images size to be a multiple of 16 bytes. If not, zeros will be
1441 * inserted between Y and U planes, and U and V planes, which violates
1442 * the YUV422P standard.
92a8337b 1443 */
4a6b8df2
TP
1444 v4l_bound_align_image(&pix->width, 48, 2048, 1,
1445 &pix->height, 32, 2048, 0,
6a6c8786 1446 pixfmt == V4L2_PIX_FMT_YUV422P ? 4 : 0);
92a8337b 1447
283e4a82 1448 v4l2_fill_mbus_format(mf, pix, xlate->code);
b36bcbd6 1449 ret = sensor_call(pcdev, pad, set_fmt, &pad_cfg, &format);
760697be
GL
1450 if (ret < 0)
1451 return ret;
06daa1af 1452
283e4a82 1453 v4l2_fill_pix_format(pix, mf);
760697be 1454
283e4a82 1455 /* Only progressive video supported so far */
5eab4983 1456 switch (mf->field) {
760697be
GL
1457 case V4L2_FIELD_ANY:
1458 case V4L2_FIELD_NONE:
283e4a82 1459 pix->field = V4L2_FIELD_NONE;
760697be
GL
1460 break;
1461 default:
1462 /* TODO: support interlaced at least in pass-through mode */
295ab497 1463 dev_err(pcdev_to_dev(pcdev), "Field type %d unsupported.\n",
5eab4983 1464 mf->field);
06daa1af
GL
1465 return -EINVAL;
1466 }
1467
283e4a82
RJ
1468 ret = soc_mbus_bytes_per_line(pix->width, xlate->host_fmt);
1469 if (ret < 0)
1470 return ret;
1471
1472 pix->bytesperline = ret;
1473 ret = soc_mbus_image_size(xlate->host_fmt, pix->bytesperline,
1474 pix->height);
1475 if (ret < 0)
1476 return ret;
1477
1478 pix->sizeimage = ret;
1479 return 0;
3bc43840
GL
1480}
1481
283e4a82
RJ
1482static int pxac_vidioc_s_fmt_vid_cap(struct file *filp, void *priv,
1483 struct v4l2_format *f)
3bc43840 1484{
283e4a82
RJ
1485 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1486 const struct soc_camera_format_xlate *xlate;
1487 struct v4l2_pix_format *pix = &f->fmt.pix;
1488 struct v4l2_subdev_format format = {
1489 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
1490 };
1491 unsigned long flags;
1492 int ret, is_busy;
1493
1494 dev_dbg(pcdev_to_dev(pcdev),
1495 "s_fmt_vid_cap(pix=%dx%d:%x)\n",
1496 pix->width, pix->height, pix->pixelformat);
1497
1498 spin_lock_irqsave(&pcdev->lock, flags);
1499 is_busy = pcdev->active || vb2_is_busy(&pcdev->vb2_vq);
1500 spin_unlock_irqrestore(&pcdev->lock, flags);
1501
1502 if (is_busy)
1503 return -EBUSY;
1504
1505 ret = pxac_vidioc_try_fmt_vid_cap(filp, priv, f);
1506 if (ret)
1507 return ret;
1508
1509 xlate = soc_mbus_xlate_by_fourcc(pcdev->user_formats,
1510 pix->pixelformat);
1511 v4l2_fill_mbus_format(&format.format, pix, xlate->code);
1512 ret = sensor_call(pcdev, pad, set_fmt, NULL, &format);
1513 if (ret < 0) {
1514 dev_warn(pcdev_to_dev(pcdev),
1515 "Failed to configure for format %x\n",
1516 pix->pixelformat);
1517 } else if (pxa_camera_check_frame(pix->width, pix->height)) {
1518 dev_warn(pcdev_to_dev(pcdev),
1519 "Camera driver produced an unsupported frame %dx%d\n",
1520 pix->width, pix->height);
1521 return -EINVAL;
1522 }
1523
1524 pcdev->current_fmt = xlate;
1525 pcdev->current_pix = *pix;
3bc43840 1526
283e4a82
RJ
1527 ret = pxa_camera_set_bus_param(pcdev);
1528 return ret;
3bc43840
GL
1529}
1530
283e4a82
RJ
1531static int pxac_vidioc_querycap(struct file *file, void *priv,
1532 struct v4l2_capability *cap)
3bc43840 1533{
283e4a82
RJ
1534 strlcpy(cap->bus_info, "platform:pxa-camera", sizeof(cap->bus_info));
1535 strlcpy(cap->driver, PXA_CAM_DRV_NAME, sizeof(cap->driver));
3bc43840 1536 strlcpy(cap->card, pxa_cam_driver_description, sizeof(cap->card));
7d96c3e4
GL
1537 cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
1538 cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
3bc43840
GL
1539
1540 return 0;
1541}
1542
283e4a82
RJ
1543static int pxac_vidioc_enum_input(struct file *file, void *priv,
1544 struct v4l2_input *i)
1545{
1546 if (i->index > 0)
1547 return -EINVAL;
1548
1549 i->type = V4L2_INPUT_TYPE_CAMERA;
1550 strlcpy(i->name, "Camera", sizeof(i->name));
1551
1552 return 0;
1553}
1554
1555static int pxac_vidioc_g_input(struct file *file, void *priv, unsigned int *i)
1556{
1557 *i = 0;
1558
1559 return 0;
1560}
1561
1562static int pxac_vidioc_s_input(struct file *file, void *priv, unsigned int i)
1563{
1564 if (i > 0)
1565 return -EINVAL;
1566
1567 return 0;
1568}
1569
1570static int pxac_fops_camera_open(struct file *filp)
1571{
1572 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1573 int ret;
1574
1575 mutex_lock(&pcdev->mlock);
1576 ret = v4l2_fh_open(filp);
1577 if (ret < 0)
1578 goto out;
1579
1580 ret = sensor_call(pcdev, core, s_power, 1);
1581 if (ret)
1582 v4l2_fh_release(filp);
1583out:
1584 mutex_unlock(&pcdev->mlock);
1585 return ret;
1586}
1587
1588static int pxac_fops_camera_release(struct file *filp)
1589{
1590 struct pxa_camera_dev *pcdev = video_drvdata(filp);
1591 int ret;
1592
1593 ret = vb2_fop_release(filp);
1594 if (ret < 0)
1595 return ret;
1596
1597 mutex_lock(&pcdev->mlock);
1598 ret = sensor_call(pcdev, core, s_power, 0);
1599 mutex_unlock(&pcdev->mlock);
1600
1601 return ret;
1602}
1603
1604static const struct v4l2_file_operations pxa_camera_fops = {
1605 .owner = THIS_MODULE,
1606 .open = pxac_fops_camera_open,
1607 .release = pxac_fops_camera_release,
1608 .read = vb2_fop_read,
1609 .poll = vb2_fop_poll,
1610 .mmap = vb2_fop_mmap,
1611 .unlocked_ioctl = video_ioctl2,
1612};
1613
1614static const struct v4l2_ioctl_ops pxa_camera_ioctl_ops = {
1615 .vidioc_querycap = pxac_vidioc_querycap,
1616
1617 .vidioc_enum_input = pxac_vidioc_enum_input,
1618 .vidioc_g_input = pxac_vidioc_g_input,
1619 .vidioc_s_input = pxac_vidioc_s_input,
1620
1621 .vidioc_enum_fmt_vid_cap = pxac_vidioc_enum_fmt_vid_cap,
1622 .vidioc_g_fmt_vid_cap = pxac_vidioc_g_fmt_vid_cap,
1623 .vidioc_s_fmt_vid_cap = pxac_vidioc_s_fmt_vid_cap,
1624 .vidioc_try_fmt_vid_cap = pxac_vidioc_try_fmt_vid_cap,
1625
1626 .vidioc_reqbufs = vb2_ioctl_reqbufs,
1627 .vidioc_create_bufs = vb2_ioctl_create_bufs,
1628 .vidioc_querybuf = vb2_ioctl_querybuf,
1629 .vidioc_qbuf = vb2_ioctl_qbuf,
1630 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1631 .vidioc_expbuf = vb2_ioctl_expbuf,
1632 .vidioc_streamon = vb2_ioctl_streamon,
1633 .vidioc_streamoff = vb2_ioctl_streamoff,
cdd657eb
RJ
1634#ifdef CONFIG_VIDEO_ADV_DEBUG
1635 .vidioc_g_register = pxac_vidioc_g_register,
1636 .vidioc_s_register = pxac_vidioc_s_register,
1637#endif
283e4a82
RJ
1638};
1639
1640static struct v4l2_clk_ops pxa_camera_mclk_ops = {
1641};
1642
1643static const struct video_device pxa_camera_videodev_template = {
1644 .name = "pxa-camera",
1645 .minor = -1,
1646 .fops = &pxa_camera_fops,
1647 .ioctl_ops = &pxa_camera_ioctl_ops,
1648 .release = video_device_release_empty,
1649 .device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING,
1650};
1651
1652static int pxa_camera_sensor_bound(struct v4l2_async_notifier *notifier,
1653 struct v4l2_subdev *subdev,
1654 struct v4l2_async_subdev *asd)
1655{
1656 int err;
1657 struct v4l2_device *v4l2_dev = notifier->v4l2_dev;
1658 struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(v4l2_dev);
1659 struct video_device *vdev = &pcdev->vdev;
1660 struct v4l2_pix_format *pix = &pcdev->current_pix;
1661 struct v4l2_subdev_format format = {
1662 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
1663 };
1664 struct v4l2_mbus_framefmt *mf = &format.format;
1665
1666 dev_info(pcdev_to_dev(pcdev), "%s(): trying to bind a device\n",
1667 __func__);
1668 mutex_lock(&pcdev->mlock);
1669 *vdev = pxa_camera_videodev_template;
1670 vdev->v4l2_dev = v4l2_dev;
1671 vdev->lock = &pcdev->mlock;
1672 pcdev->sensor = subdev;
1673 pcdev->vdev.queue = &pcdev->vb2_vq;
1674 pcdev->vdev.v4l2_dev = &pcdev->v4l2_dev;
1675 pcdev->vdev.ctrl_handler = subdev->ctrl_handler;
1676 video_set_drvdata(&pcdev->vdev, pcdev);
1677
1678 err = pxa_camera_build_formats(pcdev);
1679 if (err) {
1680 dev_err(pcdev_to_dev(pcdev), "building formats failed: %d\n",
1681 err);
1682 goto out;
1683 }
1684
1685 pcdev->current_fmt = pcdev->user_formats;
1686 pix->field = V4L2_FIELD_NONE;
1687 pix->width = DEFAULT_WIDTH;
1688 pix->height = DEFAULT_HEIGHT;
1689 pix->bytesperline =
1690 soc_mbus_bytes_per_line(pix->width,
1691 pcdev->current_fmt->host_fmt);
1692 pix->sizeimage =
1693 soc_mbus_image_size(pcdev->current_fmt->host_fmt,
1694 pix->bytesperline, pix->height);
1695 pix->pixelformat = pcdev->current_fmt->host_fmt->fourcc;
1696 v4l2_fill_mbus_format(mf, pix, pcdev->current_fmt->code);
1697 err = sensor_call(pcdev, pad, set_fmt, NULL, &format);
1698 if (err)
1699 goto out;
1700
1701 v4l2_fill_pix_format(pix, mf);
1702 pr_info("%s(): colorspace=0x%x pixfmt=0x%x\n",
1703 __func__, pix->colorspace, pix->pixelformat);
1704
1705 err = pxa_camera_init_videobuf2(pcdev);
1706 if (err)
1707 goto out;
1708
1709 err = video_register_device(&pcdev->vdev, VFL_TYPE_GRABBER, -1);
1710 if (err) {
1711 v4l2_err(v4l2_dev, "register video device failed: %d\n", err);
1712 pcdev->sensor = NULL;
1713 } else {
1714 dev_info(pcdev_to_dev(pcdev),
1715 "PXA Camera driver attached to camera %s\n",
1716 subdev->name);
1717 }
1718out:
1719 mutex_unlock(&pcdev->mlock);
1720 return err;
1721}
1722
1723static void pxa_camera_sensor_unbind(struct v4l2_async_notifier *notifier,
1724 struct v4l2_subdev *subdev,
1725 struct v4l2_async_subdev *asd)
1726{
1727 struct pxa_camera_dev *pcdev = v4l2_dev_to_pcdev(notifier->v4l2_dev);
1728
1729 mutex_lock(&pcdev->mlock);
1730 dev_info(pcdev_to_dev(pcdev),
1731 "PXA Camera driver detached from camera %s\n",
1732 subdev->name);
1733
1734 /* disable capture, disable interrupts */
1735 __raw_writel(0x3ff, pcdev->base + CICR0);
1736
1737 /* Stop DMA engine */
1738 pxa_dma_stop_channels(pcdev);
1739
1740 pxa_camera_destroy_formats(pcdev);
1741 video_unregister_device(&pcdev->vdev);
1742 pcdev->sensor = NULL;
1743
1744 mutex_unlock(&pcdev->mlock);
1745}
1746
6f28435d
RJ
1747/*
1748 * Driver probe, remove, suspend and resume operations
1749 */
7254026c 1750static int pxa_camera_suspend(struct device *dev)
3f6ac497 1751{
283e4a82 1752 struct pxa_camera_dev *pcdev = dev_get_drvdata(dev);
3f6ac497
RJ
1753 int i = 0, ret = 0;
1754
5ca11fa3
EM
1755 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR0);
1756 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR1);
1757 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR2);
1758 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR3);
1759 pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR4);
3f6ac497 1760
283e4a82 1761 if (pcdev->sensor) {
b36bcbd6 1762 ret = sensor_call(pcdev, core, s_power, 0);
497833c6
GL
1763 if (ret == -ENOIOCTLCMD)
1764 ret = 0;
1765 }
3f6ac497
RJ
1766
1767 return ret;
1768}
1769
7254026c 1770static int pxa_camera_resume(struct device *dev)
3f6ac497 1771{
283e4a82 1772 struct pxa_camera_dev *pcdev = dev_get_drvdata(dev);
3f6ac497
RJ
1773 int i = 0, ret = 0;
1774
5ca11fa3
EM
1775 __raw_writel(pcdev->save_cicr[i++] & ~CICR0_ENB, pcdev->base + CICR0);
1776 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR1);
1777 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR2);
1778 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR3);
1779 __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR4);
3f6ac497 1780
283e4a82 1781 if (pcdev->sensor) {
b36bcbd6 1782 ret = sensor_call(pcdev, core, s_power, 1);
497833c6
GL
1783 if (ret == -ENOIOCTLCMD)
1784 ret = 0;
1785 }
3f6ac497
RJ
1786
1787 /* Restart frame capture if active buffer exists */
256b0233
RJ
1788 if (!ret && pcdev->active)
1789 pxa_camera_start_capture(pcdev);
3f6ac497
RJ
1790
1791 return ret;
1792}
1793
e9a1d94f 1794static int pxa_camera_pdata_from_dt(struct device *dev,
283e4a82
RJ
1795 struct pxa_camera_dev *pcdev,
1796 struct v4l2_async_subdev *asd)
e9a1d94f
RJ
1797{
1798 u32 mclk_rate;
283e4a82 1799 struct device_node *remote, *np = dev->of_node;
e9a1d94f
RJ
1800 struct v4l2_of_endpoint ep;
1801 int err = of_property_read_u32(np, "clock-frequency",
1802 &mclk_rate);
1803 if (!err) {
1804 pcdev->platform_flags |= PXA_CAMERA_MCLK_EN;
1805 pcdev->mclk = mclk_rate;
1806 }
1807
1808 np = of_graph_get_next_endpoint(np, NULL);
1809 if (!np) {
283e4a82 1810 dev_err(dev, "could not find endpoint\n");
e9a1d94f
RJ
1811 return -EINVAL;
1812 }
1813
1814 err = v4l2_of_parse_endpoint(np, &ep);
1815 if (err) {
283e4a82 1816 dev_err(dev, "could not parse endpoint\n");
e9a1d94f
RJ
1817 goto out;
1818 }
1819
1820 switch (ep.bus.parallel.bus_width) {
1821 case 4:
1822 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_4;
1823 break;
1824 case 5:
1825 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_5;
1826 break;
1827 case 8:
1828 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_8;
1829 break;
1830 case 9:
1831 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_9;
1832 break;
1833 case 10:
1834 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10;
1835 break;
1836 default:
1837 break;
c611c908 1838 }
e9a1d94f
RJ
1839
1840 if (ep.bus.parallel.flags & V4L2_MBUS_MASTER)
1841 pcdev->platform_flags |= PXA_CAMERA_MASTER;
1842 if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
1843 pcdev->platform_flags |= PXA_CAMERA_HSP;
1844 if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
1845 pcdev->platform_flags |= PXA_CAMERA_VSP;
1846 if (ep.bus.parallel.flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
1847 pcdev->platform_flags |= PXA_CAMERA_PCLK_EN | PXA_CAMERA_PCP;
1848 if (ep.bus.parallel.flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
1849 pcdev->platform_flags |= PXA_CAMERA_PCLK_EN;
1850
283e4a82
RJ
1851 asd->match_type = V4L2_ASYNC_MATCH_OF;
1852 remote = of_graph_get_remote_port(np);
1853 if (remote) {
1854 asd->match.of.node = remote;
1855 of_node_put(remote);
1856 } else {
1857 dev_notice(dev, "no remote for %s\n", of_node_full_name(np));
1858 }
1859
e9a1d94f
RJ
1860out:
1861 of_node_put(np);
1862
1863 return err;
1864}
1865
4c62e976 1866static int pxa_camera_probe(struct platform_device *pdev)
3bc43840
GL
1867{
1868 struct pxa_camera_dev *pcdev;
1869 struct resource *res;
1870 void __iomem *base;
1e77d55a
RJ
1871 struct dma_slave_config config = {
1872 .src_addr_width = 0,
1873 .src_maxburst = 8,
1874 .direction = DMA_DEV_TO_MEM,
1875 };
1876 dma_cap_mask_t mask;
1877 struct pxad_param params;
283e4a82 1878 char clk_name[V4L2_CLK_NAME_SIZE];
02da4659 1879 int irq;
1e77d55a 1880 int err = 0, i;
3bc43840
GL
1881
1882 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1883 irq = platform_get_irq(pdev, 0);
47de201c
JL
1884 if (!res || irq < 0)
1885 return -ENODEV;
3bc43840 1886
47de201c 1887 pcdev = devm_kzalloc(&pdev->dev, sizeof(*pcdev), GFP_KERNEL);
3bc43840 1888 if (!pcdev) {
7102b773 1889 dev_err(&pdev->dev, "Could not allocate pcdev\n");
47de201c 1890 return -ENOMEM;
3bc43840
GL
1891 }
1892
47de201c
JL
1893 pcdev->clk = devm_clk_get(&pdev->dev, NULL);
1894 if (IS_ERR(pcdev->clk))
1895 return PTR_ERR(pcdev->clk);
3bc43840 1896
3bc43840
GL
1897 pcdev->res = res;
1898
1899 pcdev->pdata = pdev->dev.platform_data;
e9a1d94f 1900 if (&pdev->dev.of_node && !pcdev->pdata) {
283e4a82 1901 err = pxa_camera_pdata_from_dt(&pdev->dev, pcdev, &pcdev->asd);
e9a1d94f
RJ
1902 } else {
1903 pcdev->platform_flags = pcdev->pdata->flags;
1904 pcdev->mclk = pcdev->pdata->mclk_10khz * 10000;
283e4a82
RJ
1905 pcdev->asd.match_type = V4L2_ASYNC_MATCH_I2C;
1906 pcdev->asd.match.i2c.adapter_id =
1907 pcdev->pdata->sensor_i2c_adapter_id;
1908 pcdev->asd.match.i2c.address = pcdev->pdata->sensor_i2c_address;
e9a1d94f
RJ
1909 }
1910 if (err < 0)
1911 return err;
1912
ad5f2e85
GL
1913 if (!(pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 |
1914 PXA_CAMERA_DATAWIDTH_9 | PXA_CAMERA_DATAWIDTH_10))) {
5d28d525
GL
1915 /*
1916 * Platform hasn't set available data widths. This is bad.
1917 * Warn and use a default.
1918 */
3bc43840
GL
1919 dev_warn(&pdev->dev, "WARNING! Platform hasn't set available "
1920 "data widths, using default 10 bit\n");
1921 pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10;
1922 }
679419aa
GL
1923 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8)
1924 pcdev->width_flags = 1 << 7;
1925 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_9)
1926 pcdev->width_flags |= 1 << 8;
1927 if (pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_10)
1928 pcdev->width_flags |= 1 << 9;
cf34cba7 1929 if (!pcdev->mclk) {
3bc43840 1930 dev_warn(&pdev->dev,
cf34cba7 1931 "mclk == 0! Please, fix your platform data. "
3bc43840 1932 "Using default 20MHz\n");
cf34cba7 1933 pcdev->mclk = 20000000;
3bc43840
GL
1934 }
1935
40e2e092 1936 pcdev->mclk_divisor = mclk_get_divisor(pdev, pcdev);
cf34cba7 1937
3bc43840
GL
1938 INIT_LIST_HEAD(&pcdev->capture);
1939 spin_lock_init(&pcdev->lock);
283e4a82 1940 mutex_init(&pcdev->mlock);
3bc43840
GL
1941
1942 /*
1943 * Request the regions.
1944 */
8efdb135
SK
1945 base = devm_ioremap_resource(&pdev->dev, res);
1946 if (IS_ERR(base))
1947 return PTR_ERR(base);
1948
3bc43840
GL
1949 pcdev->irq = irq;
1950 pcdev->base = base;
3bc43840
GL
1951
1952 /* request dma */
1e77d55a
RJ
1953 dma_cap_zero(mask);
1954 dma_cap_set(DMA_SLAVE, mask);
1955 dma_cap_set(DMA_PRIVATE, mask);
1956
1957 params.prio = 0;
1958 params.drcmr = 68;
1959 pcdev->dma_chans[0] =
1960 dma_request_slave_channel_compat(mask, pxad_filter_fn,
1961 &params, &pdev->dev, "CI_Y");
1962 if (!pcdev->dma_chans[0]) {
eff505fa 1963 dev_err(&pdev->dev, "Can't request DMA for Y\n");
1e77d55a 1964 return -ENODEV;
3bc43840 1965 }
a5462e5b 1966
1e77d55a
RJ
1967 params.drcmr = 69;
1968 pcdev->dma_chans[1] =
1969 dma_request_slave_channel_compat(mask, pxad_filter_fn,
1970 &params, &pdev->dev, "CI_U");
1971 if (!pcdev->dma_chans[1]) {
1972 dev_err(&pdev->dev, "Can't request DMA for Y\n");
a5462e5b
MR
1973 goto exit_free_dma_y;
1974 }
a5462e5b 1975
1e77d55a
RJ
1976 params.drcmr = 70;
1977 pcdev->dma_chans[2] =
1978 dma_request_slave_channel_compat(mask, pxad_filter_fn,
1979 &params, &pdev->dev, "CI_V");
1980 if (!pcdev->dma_chans[2]) {
eff505fa 1981 dev_err(&pdev->dev, "Can't request DMA for V\n");
a5462e5b
MR
1982 goto exit_free_dma_u;
1983 }
3bc43840 1984
1e77d55a
RJ
1985 for (i = 0; i < 3; i++) {
1986 config.src_addr = pcdev->res->start + CIBR0 + i * 8;
1987 err = dmaengine_slave_config(pcdev->dma_chans[i], &config);
1988 if (err < 0) {
1989 dev_err(&pdev->dev, "dma slave config failed: %d\n",
1990 err);
1991 goto exit_free_dma;
1992 }
1993 }
3bc43840
GL
1994
1995 /* request irq */
47de201c
JL
1996 err = devm_request_irq(&pdev->dev, pcdev->irq, pxa_camera_irq, 0,
1997 PXA_CAM_DRV_NAME, pcdev);
3bc43840 1998 if (err) {
47de201c 1999 dev_err(&pdev->dev, "Camera interrupt register failed\n");
3bc43840
GL
2000 goto exit_free_dma;
2001 }
2002
e623ebe6 2003 tasklet_init(&pcdev->task_eof, pxa_camera_eof, (unsigned long)pcdev);
eff505fa 2004
283e4a82
RJ
2005 pxa_camera_activate(pcdev);
2006
2007 dev_set_drvdata(&pdev->dev, pcdev);
2008 err = v4l2_device_register(&pdev->dev, &pcdev->v4l2_dev);
3bc43840 2009 if (err)
47de201c 2010 goto exit_free_dma;
3bc43840 2011
283e4a82
RJ
2012 pcdev->asds[0] = &pcdev->asd;
2013 pcdev->notifier.subdevs = pcdev->asds;
2014 pcdev->notifier.num_subdevs = 1;
2015 pcdev->notifier.bound = pxa_camera_sensor_bound;
2016 pcdev->notifier.unbind = pxa_camera_sensor_unbind;
2017
2018 if (!of_have_populated_dt())
2019 pcdev->asd.match_type = V4L2_ASYNC_MATCH_I2C;
2020
2021 err = pxa_camera_init_videobuf2(pcdev);
2022 if (err)
2023 goto exit_free_v4l2dev;
3bc43840 2024
283e4a82
RJ
2025 if (pcdev->mclk) {
2026 v4l2_clk_name_i2c(clk_name, sizeof(clk_name),
2027 pcdev->asd.match.i2c.adapter_id,
2028 pcdev->asd.match.i2c.address);
2029
2030 pcdev->mclk_clk = v4l2_clk_register(&pxa_camera_mclk_ops,
2031 clk_name, NULL);
2032 if (IS_ERR(pcdev->mclk_clk))
2033 return PTR_ERR(pcdev->mclk_clk);
2034 }
2035
2036 err = v4l2_async_notifier_register(&pcdev->v4l2_dev, &pcdev->notifier);
2037 if (err)
2038 goto exit_free_clk;
2039
2040 return 0;
2041exit_free_clk:
2042 v4l2_clk_unregister(pcdev->mclk_clk);
2043exit_free_v4l2dev:
2044 v4l2_device_unregister(&pcdev->v4l2_dev);
3bc43840 2045exit_free_dma:
1e77d55a 2046 dma_release_channel(pcdev->dma_chans[2]);
a5462e5b 2047exit_free_dma_u:
1e77d55a 2048 dma_release_channel(pcdev->dma_chans[1]);
a5462e5b 2049exit_free_dma_y:
1e77d55a 2050 dma_release_channel(pcdev->dma_chans[0]);
3bc43840
GL
2051 return err;
2052}
2053
4c62e976 2054static int pxa_camera_remove(struct platform_device *pdev)
3bc43840 2055{
283e4a82 2056 struct pxa_camera_dev *pcdev = dev_get_drvdata(&pdev->dev);
3bc43840 2057
283e4a82 2058 pxa_camera_deactivate(pcdev);
1e77d55a
RJ
2059 dma_release_channel(pcdev->dma_chans[0]);
2060 dma_release_channel(pcdev->dma_chans[1]);
2061 dma_release_channel(pcdev->dma_chans[2]);
3bc43840 2062
283e4a82
RJ
2063 v4l2_clk_unregister(pcdev->mclk_clk);
2064 v4l2_device_unregister(&pcdev->v4l2_dev);
3bc43840 2065
7102b773 2066 dev_info(&pdev->dev, "PXA Camera driver unloaded\n");
3bc43840 2067
3bc43840
GL
2068 return 0;
2069}
2070
56a49194 2071static const struct dev_pm_ops pxa_camera_pm = {
7254026c
GL
2072 .suspend = pxa_camera_suspend,
2073 .resume = pxa_camera_resume,
2074};
2075
e9a1d94f
RJ
2076static const struct of_device_id pxa_camera_of_match[] = {
2077 { .compatible = "marvell,pxa270-qci", },
2078 {},
2079};
2080MODULE_DEVICE_TABLE(of, pxa_camera_of_match);
2081
3bc43840 2082static struct platform_driver pxa_camera_driver = {
6003b2ad 2083 .driver = {
3bc43840 2084 .name = PXA_CAM_DRV_NAME,
7254026c 2085 .pm = &pxa_camera_pm,
e9a1d94f 2086 .of_match_table = of_match_ptr(pxa_camera_of_match),
3bc43840
GL
2087 },
2088 .probe = pxa_camera_probe,
4c62e976 2089 .remove = pxa_camera_remove,
3bc43840
GL
2090};
2091
1d6629b1 2092module_platform_driver(pxa_camera_driver);
3bc43840
GL
2093
2094MODULE_DESCRIPTION("PXA27x SoC Camera Host driver");
2095MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
2096MODULE_LICENSE("GPL");
64dc3c1a 2097MODULE_VERSION(PXA_CAM_VERSION);
40e2e092 2098MODULE_ALIAS("platform:" PXA_CAM_DRV_NAME);
This page took 0.797602 seconds and 5 git commands to generate.