pxa_camera.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615
  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>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/io.h>
  15. #include <linux/delay.h>
  16. #include <linux/dma-mapping.h>
  17. #include <linux/errno.h>
  18. #include <linux/fs.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/kernel.h>
  21. #include <linux/mm.h>
  22. #include <linux/moduleparam.h>
  23. #include <linux/time.h>
  24. #include <linux/version.h>
  25. #include <linux/device.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/clk.h>
  28. #include <media/v4l2-common.h>
  29. #include <media/v4l2-dev.h>
  30. #include <media/videobuf-dma-sg.h>
  31. #include <media/soc_camera.h>
  32. #include <linux/videodev2.h>
  33. #include <mach/dma.h>
  34. #include <mach/camera.h>
  35. #define PXA_CAM_VERSION_CODE KERNEL_VERSION(0, 0, 5)
  36. #define PXA_CAM_DRV_NAME "pxa27x-camera"
  37. /* Camera Interface */
  38. #define CICR0 0x0000
  39. #define CICR1 0x0004
  40. #define CICR2 0x0008
  41. #define CICR3 0x000C
  42. #define CICR4 0x0010
  43. #define CISR 0x0014
  44. #define CIFR 0x0018
  45. #define CITOR 0x001C
  46. #define CIBR0 0x0028
  47. #define CIBR1 0x0030
  48. #define CIBR2 0x0038
  49. #define CICR0_DMAEN (1 << 31) /* DMA request enable */
  50. #define CICR0_PAR_EN (1 << 30) /* Parity enable */
  51. #define CICR0_SL_CAP_EN (1 << 29) /* Capture enable for slave mode */
  52. #define CICR0_ENB (1 << 28) /* Camera interface enable */
  53. #define CICR0_DIS (1 << 27) /* Camera interface disable */
  54. #define CICR0_SIM (0x7 << 24) /* Sensor interface mode mask */
  55. #define CICR0_TOM (1 << 9) /* Time-out mask */
  56. #define CICR0_RDAVM (1 << 8) /* Receive-data-available mask */
  57. #define CICR0_FEM (1 << 7) /* FIFO-empty mask */
  58. #define CICR0_EOLM (1 << 6) /* End-of-line mask */
  59. #define CICR0_PERRM (1 << 5) /* Parity-error mask */
  60. #define CICR0_QDM (1 << 4) /* Quick-disable mask */
  61. #define CICR0_CDM (1 << 3) /* Disable-done mask */
  62. #define CICR0_SOFM (1 << 2) /* Start-of-frame mask */
  63. #define CICR0_EOFM (1 << 1) /* End-of-frame mask */
  64. #define CICR0_FOM (1 << 0) /* FIFO-overrun mask */
  65. #define CICR1_TBIT (1 << 31) /* Transparency bit */
  66. #define CICR1_RGBT_CONV (0x3 << 29) /* RGBT conversion mask */
  67. #define CICR1_PPL (0x7ff << 15) /* Pixels per line mask */
  68. #define CICR1_RGB_CONV (0x7 << 12) /* RGB conversion mask */
  69. #define CICR1_RGB_F (1 << 11) /* RGB format */
  70. #define CICR1_YCBCR_F (1 << 10) /* YCbCr format */
  71. #define CICR1_RGB_BPP (0x7 << 7) /* RGB bis per pixel mask */
  72. #define CICR1_RAW_BPP (0x3 << 5) /* Raw bis per pixel mask */
  73. #define CICR1_COLOR_SP (0x3 << 3) /* Color space mask */
  74. #define CICR1_DW (0x7 << 0) /* Data width mask */
  75. #define CICR2_BLW (0xff << 24) /* Beginning-of-line pixel clock
  76. wait count mask */
  77. #define CICR2_ELW (0xff << 16) /* End-of-line pixel clock
  78. wait count mask */
  79. #define CICR2_HSW (0x3f << 10) /* Horizontal sync pulse width mask */
  80. #define CICR2_BFPW (0x3f << 3) /* Beginning-of-frame pixel clock
  81. wait count mask */
  82. #define CICR2_FSW (0x7 << 0) /* Frame stabilization
  83. wait count mask */
  84. #define CICR3_BFW (0xff << 24) /* Beginning-of-frame line clock
  85. wait count mask */
  86. #define CICR3_EFW (0xff << 16) /* End-of-frame line clock
  87. wait count mask */
  88. #define CICR3_VSW (0x3f << 10) /* Vertical sync pulse width mask */
  89. #define CICR3_BFPW (0x3f << 3) /* Beginning-of-frame pixel clock
  90. wait count mask */
  91. #define CICR3_LPF (0x7ff << 0) /* Lines per frame mask */
  92. #define CICR4_MCLK_DLY (0x3 << 24) /* MCLK Data Capture Delay mask */
  93. #define CICR4_PCLK_EN (1 << 23) /* Pixel clock enable */
  94. #define CICR4_PCP (1 << 22) /* Pixel clock polarity */
  95. #define CICR4_HSP (1 << 21) /* Horizontal sync polarity */
  96. #define CICR4_VSP (1 << 20) /* Vertical sync polarity */
  97. #define CICR4_MCLK_EN (1 << 19) /* MCLK enable */
  98. #define CICR4_FR_RATE (0x7 << 8) /* Frame rate mask */
  99. #define CICR4_DIV (0xff << 0) /* Clock divisor mask */
  100. #define CISR_FTO (1 << 15) /* FIFO time-out */
  101. #define CISR_RDAV_2 (1 << 14) /* Channel 2 receive data available */
  102. #define CISR_RDAV_1 (1 << 13) /* Channel 1 receive data available */
  103. #define CISR_RDAV_0 (1 << 12) /* Channel 0 receive data available */
  104. #define CISR_FEMPTY_2 (1 << 11) /* Channel 2 FIFO empty */
  105. #define CISR_FEMPTY_1 (1 << 10) /* Channel 1 FIFO empty */
  106. #define CISR_FEMPTY_0 (1 << 9) /* Channel 0 FIFO empty */
  107. #define CISR_EOL (1 << 8) /* End of line */
  108. #define CISR_PAR_ERR (1 << 7) /* Parity error */
  109. #define CISR_CQD (1 << 6) /* Camera interface quick disable */
  110. #define CISR_CDD (1 << 5) /* Camera interface disable done */
  111. #define CISR_SOF (1 << 4) /* Start of frame */
  112. #define CISR_EOF (1 << 3) /* End of frame */
  113. #define CISR_IFO_2 (1 << 2) /* FIFO overrun for Channel 2 */
  114. #define CISR_IFO_1 (1 << 1) /* FIFO overrun for Channel 1 */
  115. #define CISR_IFO_0 (1 << 0) /* FIFO overrun for Channel 0 */
  116. #define CIFR_FLVL2 (0x7f << 23) /* FIFO 2 level mask */
  117. #define CIFR_FLVL1 (0x7f << 16) /* FIFO 1 level mask */
  118. #define CIFR_FLVL0 (0xff << 8) /* FIFO 0 level mask */
  119. #define CIFR_THL_0 (0x3 << 4) /* Threshold Level for Channel 0 FIFO */
  120. #define CIFR_RESET_F (1 << 3) /* Reset input FIFOs */
  121. #define CIFR_FEN2 (1 << 2) /* FIFO enable for channel 2 */
  122. #define CIFR_FEN1 (1 << 1) /* FIFO enable for channel 1 */
  123. #define CIFR_FEN0 (1 << 0) /* FIFO enable for channel 0 */
  124. #define CICR0_SIM_MP (0 << 24)
  125. #define CICR0_SIM_SP (1 << 24)
  126. #define CICR0_SIM_MS (2 << 24)
  127. #define CICR0_SIM_EP (3 << 24)
  128. #define CICR0_SIM_ES (4 << 24)
  129. #define CICR1_DW_VAL(x) ((x) & CICR1_DW) /* Data bus width */
  130. #define CICR1_PPL_VAL(x) (((x) << 15) & CICR1_PPL) /* Pixels per line */
  131. #define CICR1_COLOR_SP_VAL(x) (((x) << 3) & CICR1_COLOR_SP) /* color space */
  132. #define CICR1_RGB_BPP_VAL(x) (((x) << 7) & CICR1_RGB_BPP) /* bpp for rgb */
  133. #define CICR1_RGBT_CONV_VAL(x) (((x) << 29) & CICR1_RGBT_CONV) /* rgbt conv */
  134. #define CICR2_BLW_VAL(x) (((x) << 24) & CICR2_BLW) /* Beginning-of-line pixel clock wait count */
  135. #define CICR2_ELW_VAL(x) (((x) << 16) & CICR2_ELW) /* End-of-line pixel clock wait count */
  136. #define CICR2_HSW_VAL(x) (((x) << 10) & CICR2_HSW) /* Horizontal sync pulse width */
  137. #define CICR2_BFPW_VAL(x) (((x) << 3) & CICR2_BFPW) /* Beginning-of-frame pixel clock wait count */
  138. #define CICR2_FSW_VAL(x) (((x) << 0) & CICR2_FSW) /* Frame stabilization wait count */
  139. #define CICR3_BFW_VAL(x) (((x) << 24) & CICR3_BFW) /* Beginning-of-frame line clock wait count */
  140. #define CICR3_EFW_VAL(x) (((x) << 16) & CICR3_EFW) /* End-of-frame line clock wait count */
  141. #define CICR3_VSW_VAL(x) (((x) << 11) & CICR3_VSW) /* Vertical sync pulse width */
  142. #define CICR3_LPF_VAL(x) (((x) << 0) & CICR3_LPF) /* Lines per frame */
  143. #define CICR0_IRQ_MASK (CICR0_TOM | CICR0_RDAVM | CICR0_FEM | CICR0_EOLM | \
  144. CICR0_PERRM | CICR0_QDM | CICR0_CDM | CICR0_SOFM | \
  145. CICR0_EOFM | CICR0_FOM)
  146. /*
  147. * YUV422P picture size should be a multiple of 16, so the heuristic aligns
  148. * height, width on 4 byte boundaries to reach the 16 multiple for the size.
  149. */
  150. #define YUV422P_X_Y_ALIGN 4
  151. #define YUV422P_SIZE_ALIGN YUV422P_X_Y_ALIGN * YUV422P_X_Y_ALIGN
  152. /*
  153. * Structures
  154. */
  155. enum pxa_camera_active_dma {
  156. DMA_Y = 0x1,
  157. DMA_U = 0x2,
  158. DMA_V = 0x4,
  159. };
  160. /* descriptor needed for the PXA DMA engine */
  161. struct pxa_cam_dma {
  162. dma_addr_t sg_dma;
  163. struct pxa_dma_desc *sg_cpu;
  164. size_t sg_size;
  165. int sglen;
  166. };
  167. /* buffer for one video frame */
  168. struct pxa_buffer {
  169. /* common v4l buffer stuff -- must be first */
  170. struct videobuf_buffer vb;
  171. const struct soc_camera_data_format *fmt;
  172. /* our descriptor lists for Y, U and V channels */
  173. struct pxa_cam_dma dmas[3];
  174. int inwork;
  175. enum pxa_camera_active_dma active_dma;
  176. };
  177. struct pxa_camera_dev {
  178. struct device *dev;
  179. /* PXA27x is only supposed to handle one camera on its Quick Capture
  180. * interface. If anyone ever builds hardware to enable more than
  181. * one camera, they will have to modify this driver too */
  182. struct soc_camera_device *icd;
  183. struct clk *clk;
  184. unsigned int irq;
  185. void __iomem *base;
  186. int channels;
  187. unsigned int dma_chans[3];
  188. struct pxacamera_platform_data *pdata;
  189. struct resource *res;
  190. unsigned long platform_flags;
  191. unsigned long ciclk;
  192. unsigned long mclk;
  193. u32 mclk_divisor;
  194. struct list_head capture;
  195. spinlock_t lock;
  196. struct pxa_buffer *active;
  197. struct pxa_dma_desc *sg_tail[3];
  198. u32 save_cicr[5];
  199. };
  200. static const char *pxa_cam_driver_description = "PXA_Camera";
  201. static unsigned int vid_limit = 16; /* Video memory limit, in Mb */
  202. /*
  203. * Videobuf operations
  204. */
  205. static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
  206. unsigned int *size)
  207. {
  208. struct soc_camera_device *icd = vq->priv_data;
  209. dev_dbg(&icd->dev, "count=%d, size=%d\n", *count, *size);
  210. *size = roundup(icd->width * icd->height *
  211. ((icd->current_fmt->depth + 7) >> 3), 8);
  212. if (0 == *count)
  213. *count = 32;
  214. while (*size * *count > vid_limit * 1024 * 1024)
  215. (*count)--;
  216. return 0;
  217. }
  218. static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf)
  219. {
  220. struct soc_camera_device *icd = vq->priv_data;
  221. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  222. struct pxa_camera_dev *pcdev = ici->priv;
  223. struct videobuf_dmabuf *dma = videobuf_to_dma(&buf->vb);
  224. int i;
  225. BUG_ON(in_interrupt());
  226. dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
  227. &buf->vb, buf->vb.baddr, buf->vb.bsize);
  228. /* This waits until this buffer is out of danger, i.e., until it is no
  229. * longer in STATE_QUEUED or STATE_ACTIVE */
  230. videobuf_waiton(&buf->vb, 0, 0);
  231. videobuf_dma_unmap(vq, dma);
  232. videobuf_dma_free(dma);
  233. for (i = 0; i < ARRAY_SIZE(buf->dmas); i++) {
  234. if (buf->dmas[i].sg_cpu)
  235. dma_free_coherent(pcdev->dev, buf->dmas[i].sg_size,
  236. buf->dmas[i].sg_cpu,
  237. buf->dmas[i].sg_dma);
  238. buf->dmas[i].sg_cpu = NULL;
  239. }
  240. buf->vb.state = VIDEOBUF_NEEDS_INIT;
  241. }
  242. static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev,
  243. struct pxa_buffer *buf,
  244. struct videobuf_dmabuf *dma, int channel,
  245. int sglen, int sg_start, int cibr,
  246. unsigned int size)
  247. {
  248. struct pxa_cam_dma *pxa_dma = &buf->dmas[channel];
  249. int i;
  250. if (pxa_dma->sg_cpu)
  251. dma_free_coherent(pcdev->dev, pxa_dma->sg_size,
  252. pxa_dma->sg_cpu, pxa_dma->sg_dma);
  253. pxa_dma->sg_size = (sglen + 1) * sizeof(struct pxa_dma_desc);
  254. pxa_dma->sg_cpu = dma_alloc_coherent(pcdev->dev, pxa_dma->sg_size,
  255. &pxa_dma->sg_dma, GFP_KERNEL);
  256. if (!pxa_dma->sg_cpu)
  257. return -ENOMEM;
  258. pxa_dma->sglen = sglen;
  259. for (i = 0; i < sglen; i++) {
  260. int sg_i = sg_start + i;
  261. struct scatterlist *sg = dma->sglist;
  262. unsigned int dma_len = sg_dma_len(&sg[sg_i]), xfer_len;
  263. pxa_dma->sg_cpu[i].dsadr = pcdev->res->start + cibr;
  264. pxa_dma->sg_cpu[i].dtadr = sg_dma_address(&sg[sg_i]);
  265. /* PXA27x Developer's Manual 27.4.4.1: round up to 8 bytes */
  266. xfer_len = (min(dma_len, size) + 7) & ~7;
  267. pxa_dma->sg_cpu[i].dcmd =
  268. DCMD_FLOWSRC | DCMD_BURST8 | DCMD_INCTRGADDR | xfer_len;
  269. size -= dma_len;
  270. pxa_dma->sg_cpu[i].ddadr =
  271. pxa_dma->sg_dma + (i + 1) * sizeof(struct pxa_dma_desc);
  272. }
  273. pxa_dma->sg_cpu[sglen - 1].ddadr = DDADR_STOP;
  274. pxa_dma->sg_cpu[sglen - 1].dcmd |= DCMD_ENDIRQEN;
  275. return 0;
  276. }
  277. static int pxa_videobuf_prepare(struct videobuf_queue *vq,
  278. struct videobuf_buffer *vb, enum v4l2_field field)
  279. {
  280. struct soc_camera_device *icd = vq->priv_data;
  281. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  282. struct pxa_camera_dev *pcdev = ici->priv;
  283. struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb);
  284. int ret;
  285. int sglen_y, sglen_yu = 0, sglen_u = 0, sglen_v = 0;
  286. int size_y, size_u = 0, size_v = 0;
  287. dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
  288. vb, vb->baddr, vb->bsize);
  289. /* Added list head initialization on alloc */
  290. WARN_ON(!list_empty(&vb->queue));
  291. #ifdef DEBUG
  292. /* This can be useful if you want to see if we actually fill
  293. * the buffer with something */
  294. memset((void *)vb->baddr, 0xaa, vb->bsize);
  295. #endif
  296. BUG_ON(NULL == icd->current_fmt);
  297. /* I think, in buf_prepare you only have to protect global data,
  298. * the actual buffer is yours */
  299. buf->inwork = 1;
  300. if (buf->fmt != icd->current_fmt ||
  301. vb->width != icd->width ||
  302. vb->height != icd->height ||
  303. vb->field != field) {
  304. buf->fmt = icd->current_fmt;
  305. vb->width = icd->width;
  306. vb->height = icd->height;
  307. vb->field = field;
  308. vb->state = VIDEOBUF_NEEDS_INIT;
  309. }
  310. vb->size = vb->width * vb->height * ((buf->fmt->depth + 7) >> 3);
  311. if (0 != vb->baddr && vb->bsize < vb->size) {
  312. ret = -EINVAL;
  313. goto out;
  314. }
  315. if (vb->state == VIDEOBUF_NEEDS_INIT) {
  316. unsigned int size = vb->size;
  317. struct videobuf_dmabuf *dma = videobuf_to_dma(vb);
  318. ret = videobuf_iolock(vq, vb, NULL);
  319. if (ret)
  320. goto fail;
  321. if (pcdev->channels == 3) {
  322. /* FIXME the calculations should be more precise */
  323. sglen_y = dma->sglen / 2;
  324. sglen_u = sglen_v = dma->sglen / 4 + 1;
  325. sglen_yu = sglen_y + sglen_u;
  326. size_y = size / 2;
  327. size_u = size_v = size / 4;
  328. } else {
  329. sglen_y = dma->sglen;
  330. size_y = size;
  331. }
  332. /* init DMA for Y channel */
  333. ret = pxa_init_dma_channel(pcdev, buf, dma, 0, sglen_y,
  334. 0, 0x28, size_y);
  335. if (ret) {
  336. dev_err(pcdev->dev,
  337. "DMA initialization for Y/RGB failed\n");
  338. goto fail;
  339. }
  340. if (pcdev->channels == 3) {
  341. /* init DMA for U channel */
  342. ret = pxa_init_dma_channel(pcdev, buf, dma, 1, sglen_u,
  343. sglen_y, 0x30, size_u);
  344. if (ret) {
  345. dev_err(pcdev->dev,
  346. "DMA initialization for U failed\n");
  347. goto fail_u;
  348. }
  349. /* init DMA for V channel */
  350. ret = pxa_init_dma_channel(pcdev, buf, dma, 2, sglen_v,
  351. sglen_yu, 0x38, size_v);
  352. if (ret) {
  353. dev_err(pcdev->dev,
  354. "DMA initialization for V failed\n");
  355. goto fail_v;
  356. }
  357. }
  358. vb->state = VIDEOBUF_PREPARED;
  359. }
  360. buf->inwork = 0;
  361. buf->active_dma = DMA_Y;
  362. if (pcdev->channels == 3)
  363. buf->active_dma |= DMA_U | DMA_V;
  364. return 0;
  365. fail_v:
  366. dma_free_coherent(pcdev->dev, buf->dmas[1].sg_size,
  367. buf->dmas[1].sg_cpu, buf->dmas[1].sg_dma);
  368. fail_u:
  369. dma_free_coherent(pcdev->dev, buf->dmas[0].sg_size,
  370. buf->dmas[0].sg_cpu, buf->dmas[0].sg_dma);
  371. fail:
  372. free_buffer(vq, buf);
  373. out:
  374. buf->inwork = 0;
  375. return ret;
  376. }
  377. static void pxa_videobuf_queue(struct videobuf_queue *vq,
  378. struct videobuf_buffer *vb)
  379. {
  380. struct soc_camera_device *icd = vq->priv_data;
  381. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  382. struct pxa_camera_dev *pcdev = ici->priv;
  383. struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb);
  384. struct pxa_buffer *active;
  385. unsigned long flags;
  386. int i;
  387. dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
  388. vb, vb->baddr, vb->bsize);
  389. spin_lock_irqsave(&pcdev->lock, flags);
  390. list_add_tail(&vb->queue, &pcdev->capture);
  391. vb->state = VIDEOBUF_ACTIVE;
  392. active = pcdev->active;
  393. if (!active) {
  394. unsigned long cifr, cicr0;
  395. cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
  396. __raw_writel(cifr, pcdev->base + CIFR);
  397. for (i = 0; i < pcdev->channels; i++) {
  398. DDADR(pcdev->dma_chans[i]) = buf->dmas[i].sg_dma;
  399. DCSR(pcdev->dma_chans[i]) = DCSR_RUN;
  400. pcdev->sg_tail[i] = buf->dmas[i].sg_cpu + buf->dmas[i].sglen - 1;
  401. }
  402. pcdev->active = buf;
  403. cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_ENB;
  404. __raw_writel(cicr0, pcdev->base + CICR0);
  405. } else {
  406. struct pxa_cam_dma *buf_dma;
  407. struct pxa_cam_dma *act_dma;
  408. int nents;
  409. for (i = 0; i < pcdev->channels; i++) {
  410. buf_dma = &buf->dmas[i];
  411. act_dma = &active->dmas[i];
  412. nents = buf_dma->sglen;
  413. /* Stop DMA engine */
  414. DCSR(pcdev->dma_chans[i]) = 0;
  415. /* Add the descriptors we just initialized to
  416. the currently running chain */
  417. pcdev->sg_tail[i]->ddadr = buf_dma->sg_dma;
  418. pcdev->sg_tail[i] = buf_dma->sg_cpu + buf_dma->sglen - 1;
  419. /* Setup a dummy descriptor with the DMA engines current
  420. * state
  421. */
  422. buf_dma->sg_cpu[nents].dsadr =
  423. pcdev->res->start + 0x28 + i*8; /* CIBRx */
  424. buf_dma->sg_cpu[nents].dtadr =
  425. DTADR(pcdev->dma_chans[i]);
  426. buf_dma->sg_cpu[nents].dcmd =
  427. DCMD(pcdev->dma_chans[i]);
  428. if (DDADR(pcdev->dma_chans[i]) == DDADR_STOP) {
  429. /* The DMA engine is on the last
  430. descriptor, set the next descriptors
  431. address to the descriptors we just
  432. initialized */
  433. buf_dma->sg_cpu[nents].ddadr = buf_dma->sg_dma;
  434. } else {
  435. buf_dma->sg_cpu[nents].ddadr =
  436. DDADR(pcdev->dma_chans[i]);
  437. }
  438. /* The next descriptor is the dummy descriptor */
  439. DDADR(pcdev->dma_chans[i]) = buf_dma->sg_dma + nents *
  440. sizeof(struct pxa_dma_desc);
  441. DCSR(pcdev->dma_chans[i]) = DCSR_RUN;
  442. }
  443. }
  444. spin_unlock_irqrestore(&pcdev->lock, flags);
  445. }
  446. static void pxa_videobuf_release(struct videobuf_queue *vq,
  447. struct videobuf_buffer *vb)
  448. {
  449. struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb);
  450. #ifdef DEBUG
  451. struct soc_camera_device *icd = vq->priv_data;
  452. dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
  453. vb, vb->baddr, vb->bsize);
  454. switch (vb->state) {
  455. case VIDEOBUF_ACTIVE:
  456. dev_dbg(&icd->dev, "%s (active)\n", __func__);
  457. break;
  458. case VIDEOBUF_QUEUED:
  459. dev_dbg(&icd->dev, "%s (queued)\n", __func__);
  460. break;
  461. case VIDEOBUF_PREPARED:
  462. dev_dbg(&icd->dev, "%s (prepared)\n", __func__);
  463. break;
  464. default:
  465. dev_dbg(&icd->dev, "%s (unknown)\n", __func__);
  466. break;
  467. }
  468. #endif
  469. free_buffer(vq, buf);
  470. }
  471. static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
  472. struct videobuf_buffer *vb,
  473. struct pxa_buffer *buf)
  474. {
  475. unsigned long cicr0;
  476. /* _init is used to debug races, see comment in pxa_camera_reqbufs() */
  477. list_del_init(&vb->queue);
  478. vb->state = VIDEOBUF_DONE;
  479. do_gettimeofday(&vb->ts);
  480. vb->field_count++;
  481. wake_up(&vb->done);
  482. if (list_empty(&pcdev->capture)) {
  483. pcdev->active = NULL;
  484. DCSR(pcdev->dma_chans[0]) = 0;
  485. DCSR(pcdev->dma_chans[1]) = 0;
  486. DCSR(pcdev->dma_chans[2]) = 0;
  487. cicr0 = __raw_readl(pcdev->base + CICR0) & ~CICR0_ENB;
  488. __raw_writel(cicr0, pcdev->base + CICR0);
  489. return;
  490. }
  491. pcdev->active = list_entry(pcdev->capture.next,
  492. struct pxa_buffer, vb.queue);
  493. }
  494. static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev,
  495. enum pxa_camera_active_dma act_dma)
  496. {
  497. struct pxa_buffer *buf;
  498. unsigned long flags;
  499. u32 status, camera_status, overrun;
  500. struct videobuf_buffer *vb;
  501. unsigned long cifr, cicr0;
  502. spin_lock_irqsave(&pcdev->lock, flags);
  503. status = DCSR(channel);
  504. DCSR(channel) = status | DCSR_ENDINTR;
  505. if (status & DCSR_BUSERR) {
  506. dev_err(pcdev->dev, "DMA Bus Error IRQ!\n");
  507. goto out;
  508. }
  509. if (!(status & DCSR_ENDINTR)) {
  510. dev_err(pcdev->dev, "Unknown DMA IRQ source, "
  511. "status: 0x%08x\n", status);
  512. goto out;
  513. }
  514. if (!pcdev->active) {
  515. dev_err(pcdev->dev, "DMA End IRQ with no active buffer!\n");
  516. goto out;
  517. }
  518. camera_status = __raw_readl(pcdev->base + CISR);
  519. overrun = CISR_IFO_0;
  520. if (pcdev->channels == 3)
  521. overrun |= CISR_IFO_1 | CISR_IFO_2;
  522. if (camera_status & overrun) {
  523. dev_dbg(pcdev->dev, "FIFO overrun! CISR: %x\n", camera_status);
  524. /* Stop the Capture Interface */
  525. cicr0 = __raw_readl(pcdev->base + CICR0) & ~CICR0_ENB;
  526. __raw_writel(cicr0, pcdev->base + CICR0);
  527. /* Stop DMA */
  528. DCSR(channel) = 0;
  529. /* Reset the FIFOs */
  530. cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
  531. __raw_writel(cifr, pcdev->base + CIFR);
  532. /* Enable End-Of-Frame Interrupt */
  533. cicr0 &= ~CICR0_EOFM;
  534. __raw_writel(cicr0, pcdev->base + CICR0);
  535. /* Restart the Capture Interface */
  536. __raw_writel(cicr0 | CICR0_ENB, pcdev->base + CICR0);
  537. goto out;
  538. }
  539. vb = &pcdev->active->vb;
  540. buf = container_of(vb, struct pxa_buffer, vb);
  541. WARN_ON(buf->inwork || list_empty(&vb->queue));
  542. dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
  543. vb, vb->baddr, vb->bsize);
  544. buf->active_dma &= ~act_dma;
  545. if (!buf->active_dma)
  546. pxa_camera_wakeup(pcdev, vb, buf);
  547. out:
  548. spin_unlock_irqrestore(&pcdev->lock, flags);
  549. }
  550. static void pxa_camera_dma_irq_y(int channel, void *data)
  551. {
  552. struct pxa_camera_dev *pcdev = data;
  553. pxa_camera_dma_irq(channel, pcdev, DMA_Y);
  554. }
  555. static void pxa_camera_dma_irq_u(int channel, void *data)
  556. {
  557. struct pxa_camera_dev *pcdev = data;
  558. pxa_camera_dma_irq(channel, pcdev, DMA_U);
  559. }
  560. static void pxa_camera_dma_irq_v(int channel, void *data)
  561. {
  562. struct pxa_camera_dev *pcdev = data;
  563. pxa_camera_dma_irq(channel, pcdev, DMA_V);
  564. }
  565. static struct videobuf_queue_ops pxa_videobuf_ops = {
  566. .buf_setup = pxa_videobuf_setup,
  567. .buf_prepare = pxa_videobuf_prepare,
  568. .buf_queue = pxa_videobuf_queue,
  569. .buf_release = pxa_videobuf_release,
  570. };
  571. static void pxa_camera_init_videobuf(struct videobuf_queue *q,
  572. struct soc_camera_device *icd)
  573. {
  574. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  575. struct pxa_camera_dev *pcdev = ici->priv;
  576. /* We must pass NULL as dev pointer, then all pci_* dma operations
  577. * transform to normal dma_* ones. */
  578. videobuf_queue_sg_init(q, &pxa_videobuf_ops, NULL, &pcdev->lock,
  579. V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE,
  580. sizeof(struct pxa_buffer), icd);
  581. }
  582. static u32 mclk_get_divisor(struct pxa_camera_dev *pcdev)
  583. {
  584. unsigned long mclk = pcdev->mclk;
  585. u32 div;
  586. unsigned long lcdclk;
  587. lcdclk = clk_get_rate(pcdev->clk);
  588. pcdev->ciclk = lcdclk;
  589. /* mclk <= ciclk / 4 (27.4.2) */
  590. if (mclk > lcdclk / 4) {
  591. mclk = lcdclk / 4;
  592. dev_warn(pcdev->dev, "Limiting master clock to %lu\n", mclk);
  593. }
  594. /* We verify mclk != 0, so if anyone breaks it, here comes their Oops */
  595. div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1;
  596. /* If we're not supplying MCLK, leave it at 0 */
  597. if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
  598. pcdev->mclk = lcdclk / (2 * (div + 1));
  599. dev_dbg(pcdev->dev, "LCD clock %luHz, target freq %luHz, "
  600. "divisor %u\n", lcdclk, mclk, div);
  601. return div;
  602. }
  603. static void recalculate_fifo_timeout(struct pxa_camera_dev *pcdev,
  604. unsigned long pclk)
  605. {
  606. /* We want a timeout > 1 pixel time, not ">=" */
  607. u32 ciclk_per_pixel = pcdev->ciclk / pclk + 1;
  608. __raw_writel(ciclk_per_pixel, pcdev->base + CITOR);
  609. }
  610. static void pxa_camera_activate(struct pxa_camera_dev *pcdev)
  611. {
  612. struct pxacamera_platform_data *pdata = pcdev->pdata;
  613. u32 cicr4 = 0;
  614. dev_dbg(pcdev->dev, "Registered platform device at %p data %p\n",
  615. pcdev, pdata);
  616. if (pdata && pdata->init) {
  617. dev_dbg(pcdev->dev, "%s: Init gpios\n", __func__);
  618. pdata->init(pcdev->dev);
  619. }
  620. /* disable all interrupts */
  621. __raw_writel(0x3ff, pcdev->base + CICR0);
  622. if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
  623. cicr4 |= CICR4_PCLK_EN;
  624. if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
  625. cicr4 |= CICR4_MCLK_EN;
  626. if (pcdev->platform_flags & PXA_CAMERA_PCP)
  627. cicr4 |= CICR4_PCP;
  628. if (pcdev->platform_flags & PXA_CAMERA_HSP)
  629. cicr4 |= CICR4_HSP;
  630. if (pcdev->platform_flags & PXA_CAMERA_VSP)
  631. cicr4 |= CICR4_VSP;
  632. __raw_writel(pcdev->mclk_divisor | cicr4, pcdev->base + CICR4);
  633. if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
  634. /* Initialise the timeout under the assumption pclk = mclk */
  635. recalculate_fifo_timeout(pcdev, pcdev->mclk);
  636. else
  637. /* "Safe default" - 13MHz */
  638. recalculate_fifo_timeout(pcdev, 13000000);
  639. clk_enable(pcdev->clk);
  640. }
  641. static void pxa_camera_deactivate(struct pxa_camera_dev *pcdev)
  642. {
  643. clk_disable(pcdev->clk);
  644. }
  645. static irqreturn_t pxa_camera_irq(int irq, void *data)
  646. {
  647. struct pxa_camera_dev *pcdev = data;
  648. unsigned long status, cicr0;
  649. status = __raw_readl(pcdev->base + CISR);
  650. dev_dbg(pcdev->dev, "Camera interrupt status 0x%lx\n", status);
  651. if (!status)
  652. return IRQ_NONE;
  653. __raw_writel(status, pcdev->base + CISR);
  654. if (status & CISR_EOF) {
  655. int i;
  656. for (i = 0; i < pcdev->channels; i++) {
  657. DDADR(pcdev->dma_chans[i]) =
  658. pcdev->active->dmas[i].sg_dma;
  659. DCSR(pcdev->dma_chans[i]) = DCSR_RUN;
  660. }
  661. cicr0 = __raw_readl(pcdev->base + CICR0) | CICR0_EOFM;
  662. __raw_writel(cicr0, pcdev->base + CICR0);
  663. }
  664. return IRQ_HANDLED;
  665. }
  666. /*
  667. * The following two functions absolutely depend on the fact, that
  668. * there can be only one camera on PXA quick capture interface
  669. * Called with .video_lock held
  670. */
  671. static int pxa_camera_add_device(struct soc_camera_device *icd)
  672. {
  673. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  674. struct pxa_camera_dev *pcdev = ici->priv;
  675. int ret;
  676. if (pcdev->icd) {
  677. ret = -EBUSY;
  678. goto ebusy;
  679. }
  680. dev_info(&icd->dev, "PXA Camera driver attached to camera %d\n",
  681. icd->devnum);
  682. pxa_camera_activate(pcdev);
  683. ret = icd->ops->init(icd);
  684. if (!ret)
  685. pcdev->icd = icd;
  686. ebusy:
  687. return ret;
  688. }
  689. /* Called with .video_lock held */
  690. static void pxa_camera_remove_device(struct soc_camera_device *icd)
  691. {
  692. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  693. struct pxa_camera_dev *pcdev = ici->priv;
  694. BUG_ON(icd != pcdev->icd);
  695. dev_info(&icd->dev, "PXA Camera driver detached from camera %d\n",
  696. icd->devnum);
  697. /* disable capture, disable interrupts */
  698. __raw_writel(0x3ff, pcdev->base + CICR0);
  699. /* Stop DMA engine */
  700. DCSR(pcdev->dma_chans[0]) = 0;
  701. DCSR(pcdev->dma_chans[1]) = 0;
  702. DCSR(pcdev->dma_chans[2]) = 0;
  703. icd->ops->release(icd);
  704. pxa_camera_deactivate(pcdev);
  705. pcdev->icd = NULL;
  706. }
  707. static int test_platform_param(struct pxa_camera_dev *pcdev,
  708. unsigned char buswidth, unsigned long *flags)
  709. {
  710. /*
  711. * Platform specified synchronization and pixel clock polarities are
  712. * only a recommendation and are only used during probing. The PXA270
  713. * quick capture interface supports both.
  714. */
  715. *flags = (pcdev->platform_flags & PXA_CAMERA_MASTER ?
  716. SOCAM_MASTER : SOCAM_SLAVE) |
  717. SOCAM_HSYNC_ACTIVE_HIGH |
  718. SOCAM_HSYNC_ACTIVE_LOW |
  719. SOCAM_VSYNC_ACTIVE_HIGH |
  720. SOCAM_VSYNC_ACTIVE_LOW |
  721. SOCAM_DATA_ACTIVE_HIGH |
  722. SOCAM_PCLK_SAMPLE_RISING |
  723. SOCAM_PCLK_SAMPLE_FALLING;
  724. /* If requested data width is supported by the platform, use it */
  725. switch (buswidth) {
  726. case 10:
  727. if (!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_10))
  728. return -EINVAL;
  729. *flags |= SOCAM_DATAWIDTH_10;
  730. break;
  731. case 9:
  732. if (!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_9))
  733. return -EINVAL;
  734. *flags |= SOCAM_DATAWIDTH_9;
  735. break;
  736. case 8:
  737. if (!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8))
  738. return -EINVAL;
  739. *flags |= SOCAM_DATAWIDTH_8;
  740. break;
  741. default:
  742. return -EINVAL;
  743. }
  744. return 0;
  745. }
  746. static int pxa_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
  747. {
  748. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  749. struct pxa_camera_dev *pcdev = ici->priv;
  750. unsigned long dw, bpp, bus_flags, camera_flags, common_flags;
  751. u32 cicr0, cicr1, cicr2, cicr3, cicr4 = 0;
  752. int ret = test_platform_param(pcdev, icd->buswidth, &bus_flags);
  753. if (ret < 0)
  754. return ret;
  755. camera_flags = icd->ops->query_bus_param(icd);
  756. common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags);
  757. if (!common_flags)
  758. return -EINVAL;
  759. pcdev->channels = 1;
  760. /* Make choises, based on platform preferences */
  761. if ((common_flags & SOCAM_HSYNC_ACTIVE_HIGH) &&
  762. (common_flags & SOCAM_HSYNC_ACTIVE_LOW)) {
  763. if (pcdev->platform_flags & PXA_CAMERA_HSP)
  764. common_flags &= ~SOCAM_HSYNC_ACTIVE_HIGH;
  765. else
  766. common_flags &= ~SOCAM_HSYNC_ACTIVE_LOW;
  767. }
  768. if ((common_flags & SOCAM_VSYNC_ACTIVE_HIGH) &&
  769. (common_flags & SOCAM_VSYNC_ACTIVE_LOW)) {
  770. if (pcdev->platform_flags & PXA_CAMERA_VSP)
  771. common_flags &= ~SOCAM_VSYNC_ACTIVE_HIGH;
  772. else
  773. common_flags &= ~SOCAM_VSYNC_ACTIVE_LOW;
  774. }
  775. if ((common_flags & SOCAM_PCLK_SAMPLE_RISING) &&
  776. (common_flags & SOCAM_PCLK_SAMPLE_FALLING)) {
  777. if (pcdev->platform_flags & PXA_CAMERA_PCP)
  778. common_flags &= ~SOCAM_PCLK_SAMPLE_RISING;
  779. else
  780. common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING;
  781. }
  782. ret = icd->ops->set_bus_param(icd, common_flags);
  783. if (ret < 0)
  784. return ret;
  785. /* Datawidth is now guaranteed to be equal to one of the three values.
  786. * We fix bit-per-pixel equal to data-width... */
  787. switch (common_flags & SOCAM_DATAWIDTH_MASK) {
  788. case SOCAM_DATAWIDTH_10:
  789. dw = 4;
  790. bpp = 0x40;
  791. break;
  792. case SOCAM_DATAWIDTH_9:
  793. dw = 3;
  794. bpp = 0x20;
  795. break;
  796. default:
  797. /* Actually it can only be 8 now,
  798. * default is just to silence compiler warnings */
  799. case SOCAM_DATAWIDTH_8:
  800. dw = 2;
  801. bpp = 0;
  802. }
  803. if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
  804. cicr4 |= CICR4_PCLK_EN;
  805. if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN)
  806. cicr4 |= CICR4_MCLK_EN;
  807. if (common_flags & SOCAM_PCLK_SAMPLE_FALLING)
  808. cicr4 |= CICR4_PCP;
  809. if (common_flags & SOCAM_HSYNC_ACTIVE_LOW)
  810. cicr4 |= CICR4_HSP;
  811. if (common_flags & SOCAM_VSYNC_ACTIVE_LOW)
  812. cicr4 |= CICR4_VSP;
  813. cicr0 = __raw_readl(pcdev->base + CICR0);
  814. if (cicr0 & CICR0_ENB)
  815. __raw_writel(cicr0 & ~CICR0_ENB, pcdev->base + CICR0);
  816. cicr1 = CICR1_PPL_VAL(icd->width - 1) | bpp | dw;
  817. switch (pixfmt) {
  818. case V4L2_PIX_FMT_YUV422P:
  819. pcdev->channels = 3;
  820. cicr1 |= CICR1_YCBCR_F;
  821. /*
  822. * Normally, pxa bus wants as input UYVY format. We allow all
  823. * reorderings of the YUV422 format, as no processing is done,
  824. * and the YUV stream is just passed through without any
  825. * transformation. Note that UYVY is the only format that
  826. * should be used if pxa framebuffer Overlay2 is used.
  827. */
  828. case V4L2_PIX_FMT_UYVY:
  829. case V4L2_PIX_FMT_VYUY:
  830. case V4L2_PIX_FMT_YUYV:
  831. case V4L2_PIX_FMT_YVYU:
  832. cicr1 |= CICR1_COLOR_SP_VAL(2);
  833. break;
  834. case V4L2_PIX_FMT_RGB555:
  835. cicr1 |= CICR1_RGB_BPP_VAL(1) | CICR1_RGBT_CONV_VAL(2) |
  836. CICR1_TBIT | CICR1_COLOR_SP_VAL(1);
  837. break;
  838. case V4L2_PIX_FMT_RGB565:
  839. cicr1 |= CICR1_COLOR_SP_VAL(1) | CICR1_RGB_BPP_VAL(2);
  840. break;
  841. }
  842. cicr2 = 0;
  843. cicr3 = CICR3_LPF_VAL(icd->height - 1) |
  844. CICR3_BFW_VAL(min((unsigned short)255, icd->y_skip_top));
  845. cicr4 |= pcdev->mclk_divisor;
  846. __raw_writel(cicr1, pcdev->base + CICR1);
  847. __raw_writel(cicr2, pcdev->base + CICR2);
  848. __raw_writel(cicr3, pcdev->base + CICR3);
  849. __raw_writel(cicr4, pcdev->base + CICR4);
  850. /* CIF interrupts are not used, only DMA */
  851. cicr0 = (cicr0 & CICR0_ENB) | (pcdev->platform_flags & PXA_CAMERA_MASTER ?
  852. CICR0_SIM_MP : (CICR0_SL_CAP_EN | CICR0_SIM_SP));
  853. cicr0 |= CICR0_DMAEN | CICR0_IRQ_MASK;
  854. __raw_writel(cicr0, pcdev->base + CICR0);
  855. return 0;
  856. }
  857. static int pxa_camera_try_bus_param(struct soc_camera_device *icd,
  858. unsigned char buswidth)
  859. {
  860. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  861. struct pxa_camera_dev *pcdev = ici->priv;
  862. unsigned long bus_flags, camera_flags;
  863. int ret = test_platform_param(pcdev, buswidth, &bus_flags);
  864. if (ret < 0)
  865. return ret;
  866. camera_flags = icd->ops->query_bus_param(icd);
  867. return soc_camera_bus_param_compatible(camera_flags, bus_flags) ? 0 : -EINVAL;
  868. }
  869. static const struct soc_camera_data_format pxa_camera_formats[] = {
  870. {
  871. .name = "Planar YUV422 16 bit",
  872. .depth = 16,
  873. .fourcc = V4L2_PIX_FMT_YUV422P,
  874. .colorspace = V4L2_COLORSPACE_JPEG,
  875. },
  876. };
  877. static bool buswidth_supported(struct soc_camera_device *icd, int depth)
  878. {
  879. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  880. struct pxa_camera_dev *pcdev = ici->priv;
  881. switch (depth) {
  882. case 8:
  883. return !!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8);
  884. case 9:
  885. return !!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_9);
  886. case 10:
  887. return !!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_10);
  888. }
  889. return false;
  890. }
  891. static int required_buswidth(const struct soc_camera_data_format *fmt)
  892. {
  893. switch (fmt->fourcc) {
  894. case V4L2_PIX_FMT_UYVY:
  895. case V4L2_PIX_FMT_VYUY:
  896. case V4L2_PIX_FMT_YUYV:
  897. case V4L2_PIX_FMT_YVYU:
  898. case V4L2_PIX_FMT_RGB565:
  899. case V4L2_PIX_FMT_RGB555:
  900. return 8;
  901. default:
  902. return fmt->depth;
  903. }
  904. }
  905. static int pxa_camera_get_formats(struct soc_camera_device *icd, int idx,
  906. struct soc_camera_format_xlate *xlate)
  907. {
  908. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  909. int formats = 0, buswidth, ret;
  910. buswidth = required_buswidth(icd->formats + idx);
  911. if (!buswidth_supported(icd, buswidth))
  912. return 0;
  913. ret = pxa_camera_try_bus_param(icd, buswidth);
  914. if (ret < 0)
  915. return 0;
  916. switch (icd->formats[idx].fourcc) {
  917. case V4L2_PIX_FMT_UYVY:
  918. formats++;
  919. if (xlate) {
  920. xlate->host_fmt = &pxa_camera_formats[0];
  921. xlate->cam_fmt = icd->formats + idx;
  922. xlate->buswidth = buswidth;
  923. xlate++;
  924. dev_dbg(&ici->dev, "Providing format %s using %s\n",
  925. pxa_camera_formats[0].name,
  926. icd->formats[idx].name);
  927. }
  928. case V4L2_PIX_FMT_VYUY:
  929. case V4L2_PIX_FMT_YUYV:
  930. case V4L2_PIX_FMT_YVYU:
  931. case V4L2_PIX_FMT_RGB565:
  932. case V4L2_PIX_FMT_RGB555:
  933. formats++;
  934. if (xlate) {
  935. xlate->host_fmt = icd->formats + idx;
  936. xlate->cam_fmt = icd->formats + idx;
  937. xlate->buswidth = buswidth;
  938. xlate++;
  939. dev_dbg(&ici->dev, "Providing format %s packed\n",
  940. icd->formats[idx].name);
  941. }
  942. break;
  943. default:
  944. /* Generic pass-through */
  945. formats++;
  946. if (xlate) {
  947. xlate->host_fmt = icd->formats + idx;
  948. xlate->cam_fmt = icd->formats + idx;
  949. xlate->buswidth = icd->formats[idx].depth;
  950. xlate++;
  951. dev_dbg(&ici->dev,
  952. "Providing format %s in pass-through mode\n",
  953. icd->formats[idx].name);
  954. }
  955. }
  956. return formats;
  957. }
  958. static int pxa_camera_set_crop(struct soc_camera_device *icd,
  959. struct v4l2_rect *rect)
  960. {
  961. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  962. struct pxa_camera_dev *pcdev = ici->priv;
  963. struct soc_camera_sense sense = {
  964. .master_clock = pcdev->mclk,
  965. .pixel_clock_max = pcdev->ciclk / 4,
  966. };
  967. int ret;
  968. /* If PCLK is used to latch data from the sensor, check sense */
  969. if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
  970. icd->sense = &sense;
  971. ret = icd->ops->set_crop(icd, rect);
  972. icd->sense = NULL;
  973. if (ret < 0) {
  974. dev_warn(&ici->dev, "Failed to crop to %ux%u@%u:%u\n",
  975. rect->width, rect->height, rect->left, rect->top);
  976. } else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
  977. if (sense.pixel_clock > sense.pixel_clock_max) {
  978. dev_err(&ici->dev,
  979. "pixel clock %lu set by the camera too high!",
  980. sense.pixel_clock);
  981. return -EIO;
  982. }
  983. recalculate_fifo_timeout(pcdev, sense.pixel_clock);
  984. }
  985. return ret;
  986. }
  987. static int pxa_camera_set_fmt(struct soc_camera_device *icd,
  988. struct v4l2_format *f)
  989. {
  990. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  991. struct pxa_camera_dev *pcdev = ici->priv;
  992. const struct soc_camera_data_format *cam_fmt = NULL;
  993. const struct soc_camera_format_xlate *xlate = NULL;
  994. struct soc_camera_sense sense = {
  995. .master_clock = pcdev->mclk,
  996. .pixel_clock_max = pcdev->ciclk / 4,
  997. };
  998. struct v4l2_pix_format *pix = &f->fmt.pix;
  999. struct v4l2_format cam_f = *f;
  1000. int ret;
  1001. xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
  1002. if (!xlate) {
  1003. dev_warn(&ici->dev, "Format %x not found\n", pix->pixelformat);
  1004. return -EINVAL;
  1005. }
  1006. cam_fmt = xlate->cam_fmt;
  1007. /* If PCLK is used to latch data from the sensor, check sense */
  1008. if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN)
  1009. icd->sense = &sense;
  1010. cam_f.fmt.pix.pixelformat = cam_fmt->fourcc;
  1011. ret = icd->ops->set_fmt(icd, &cam_f);
  1012. icd->sense = NULL;
  1013. if (ret < 0) {
  1014. dev_warn(&ici->dev, "Failed to configure for format %x\n",
  1015. pix->pixelformat);
  1016. } else if (sense.flags & SOCAM_SENSE_PCLK_CHANGED) {
  1017. if (sense.pixel_clock > sense.pixel_clock_max) {
  1018. dev_err(&ici->dev,
  1019. "pixel clock %lu set by the camera too high!",
  1020. sense.pixel_clock);
  1021. return -EIO;
  1022. }
  1023. recalculate_fifo_timeout(pcdev, sense.pixel_clock);
  1024. }
  1025. if (!ret) {
  1026. icd->buswidth = xlate->buswidth;
  1027. icd->current_fmt = xlate->host_fmt;
  1028. }
  1029. return ret;
  1030. }
  1031. static int pxa_camera_try_fmt(struct soc_camera_device *icd,
  1032. struct v4l2_format *f)
  1033. {
  1034. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  1035. const struct soc_camera_format_xlate *xlate;
  1036. struct v4l2_pix_format *pix = &f->fmt.pix;
  1037. __u32 pixfmt = pix->pixelformat;
  1038. enum v4l2_field field;
  1039. int ret;
  1040. xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
  1041. if (!xlate) {
  1042. dev_warn(&ici->dev, "Format %x not found\n", pixfmt);
  1043. return -EINVAL;
  1044. }
  1045. /* limit to pxa hardware capabilities */
  1046. if (pix->height < 32)
  1047. pix->height = 32;
  1048. if (pix->height > 2048)
  1049. pix->height = 2048;
  1050. if (pix->width < 48)
  1051. pix->width = 48;
  1052. if (pix->width > 2048)
  1053. pix->width = 2048;
  1054. pix->width &= ~0x01;
  1055. /*
  1056. * YUV422P planar format requires images size to be a 16 bytes
  1057. * multiple. If not, zeros will be inserted between Y and U planes, and
  1058. * U and V planes, and YUV422P standard would be violated.
  1059. */
  1060. if (xlate->host_fmt->fourcc == V4L2_PIX_FMT_YUV422P) {
  1061. if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN))
  1062. pix->height = ALIGN(pix->height, YUV422P_X_Y_ALIGN);
  1063. if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN))
  1064. pix->width = ALIGN(pix->width, YUV422P_X_Y_ALIGN);
  1065. }
  1066. pix->bytesperline = pix->width *
  1067. DIV_ROUND_UP(xlate->host_fmt->depth, 8);
  1068. pix->sizeimage = pix->height * pix->bytesperline;
  1069. /* camera has to see its format, but the user the original one */
  1070. pix->pixelformat = xlate->cam_fmt->fourcc;
  1071. /* limit to sensor capabilities */
  1072. ret = icd->ops->try_fmt(icd, f);
  1073. pix->pixelformat = xlate->host_fmt->fourcc;
  1074. field = pix->field;
  1075. if (field == V4L2_FIELD_ANY) {
  1076. pix->field = V4L2_FIELD_NONE;
  1077. } else if (field != V4L2_FIELD_NONE) {
  1078. dev_err(&icd->dev, "Field type %d unsupported.\n", field);
  1079. return -EINVAL;
  1080. }
  1081. return ret;
  1082. }
  1083. static int pxa_camera_reqbufs(struct soc_camera_file *icf,
  1084. struct v4l2_requestbuffers *p)
  1085. {
  1086. int i;
  1087. /* This is for locking debugging only. I removed spinlocks and now I
  1088. * check whether .prepare is ever called on a linked buffer, or whether
  1089. * a dma IRQ can occur for an in-work or unlinked buffer. Until now
  1090. * it hadn't triggered */
  1091. for (i = 0; i < p->count; i++) {
  1092. struct pxa_buffer *buf = container_of(icf->vb_vidq.bufs[i],
  1093. struct pxa_buffer, vb);
  1094. buf->inwork = 0;
  1095. INIT_LIST_HEAD(&buf->vb.queue);
  1096. }
  1097. return 0;
  1098. }
  1099. static unsigned int pxa_camera_poll(struct file *file, poll_table *pt)
  1100. {
  1101. struct soc_camera_file *icf = file->private_data;
  1102. struct pxa_buffer *buf;
  1103. buf = list_entry(icf->vb_vidq.stream.next, struct pxa_buffer,
  1104. vb.stream);
  1105. poll_wait(file, &buf->vb.done, pt);
  1106. if (buf->vb.state == VIDEOBUF_DONE ||
  1107. buf->vb.state == VIDEOBUF_ERROR)
  1108. return POLLIN|POLLRDNORM;
  1109. return 0;
  1110. }
  1111. static int pxa_camera_querycap(struct soc_camera_host *ici,
  1112. struct v4l2_capability *cap)
  1113. {
  1114. /* cap->name is set by the firendly caller:-> */
  1115. strlcpy(cap->card, pxa_cam_driver_description, sizeof(cap->card));
  1116. cap->version = PXA_CAM_VERSION_CODE;
  1117. cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
  1118. return 0;
  1119. }
  1120. static int pxa_camera_suspend(struct soc_camera_device *icd, pm_message_t state)
  1121. {
  1122. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  1123. struct pxa_camera_dev *pcdev = ici->priv;
  1124. int i = 0, ret = 0;
  1125. pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR0);
  1126. pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR1);
  1127. pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR2);
  1128. pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR3);
  1129. pcdev->save_cicr[i++] = __raw_readl(pcdev->base + CICR4);
  1130. if ((pcdev->icd) && (pcdev->icd->ops->suspend))
  1131. ret = pcdev->icd->ops->suspend(pcdev->icd, state);
  1132. return ret;
  1133. }
  1134. static int pxa_camera_resume(struct soc_camera_device *icd)
  1135. {
  1136. struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
  1137. struct pxa_camera_dev *pcdev = ici->priv;
  1138. int i = 0, ret = 0;
  1139. DRCMR(68) = pcdev->dma_chans[0] | DRCMR_MAPVLD;
  1140. DRCMR(69) = pcdev->dma_chans[1] | DRCMR_MAPVLD;
  1141. DRCMR(70) = pcdev->dma_chans[2] | DRCMR_MAPVLD;
  1142. __raw_writel(pcdev->save_cicr[i++] & ~CICR0_ENB, pcdev->base + CICR0);
  1143. __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR1);
  1144. __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR2);
  1145. __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR3);
  1146. __raw_writel(pcdev->save_cicr[i++], pcdev->base + CICR4);
  1147. if ((pcdev->icd) && (pcdev->icd->ops->resume))
  1148. ret = pcdev->icd->ops->resume(pcdev->icd);
  1149. /* Restart frame capture if active buffer exists */
  1150. if (!ret && pcdev->active) {
  1151. unsigned long cifr, cicr0;
  1152. /* Reset the FIFOs */
  1153. cifr = __raw_readl(pcdev->base + CIFR) | CIFR_RESET_F;
  1154. __raw_writel(cifr, pcdev->base + CIFR);
  1155. cicr0 = __raw_readl(pcdev->base + CICR0);
  1156. cicr0 &= ~CICR0_EOFM; /* Enable End-Of-Frame Interrupt */
  1157. cicr0 |= CICR0_ENB; /* Restart the Capture Interface */
  1158. __raw_writel(cicr0, pcdev->base + CICR0);
  1159. }
  1160. return ret;
  1161. }
  1162. static struct soc_camera_host_ops pxa_soc_camera_host_ops = {
  1163. .owner = THIS_MODULE,
  1164. .add = pxa_camera_add_device,
  1165. .remove = pxa_camera_remove_device,
  1166. .suspend = pxa_camera_suspend,
  1167. .resume = pxa_camera_resume,
  1168. .set_crop = pxa_camera_set_crop,
  1169. .get_formats = pxa_camera_get_formats,
  1170. .set_fmt = pxa_camera_set_fmt,
  1171. .try_fmt = pxa_camera_try_fmt,
  1172. .init_videobuf = pxa_camera_init_videobuf,
  1173. .reqbufs = pxa_camera_reqbufs,
  1174. .poll = pxa_camera_poll,
  1175. .querycap = pxa_camera_querycap,
  1176. .set_bus_param = pxa_camera_set_bus_param,
  1177. };
  1178. /* Should be allocated dynamically too, but we have only one. */
  1179. static struct soc_camera_host pxa_soc_camera_host = {
  1180. .drv_name = PXA_CAM_DRV_NAME,
  1181. .ops = &pxa_soc_camera_host_ops,
  1182. };
  1183. static int pxa_camera_probe(struct platform_device *pdev)
  1184. {
  1185. struct pxa_camera_dev *pcdev;
  1186. struct resource *res;
  1187. void __iomem *base;
  1188. int irq;
  1189. int err = 0;
  1190. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1191. irq = platform_get_irq(pdev, 0);
  1192. if (!res || irq < 0) {
  1193. err = -ENODEV;
  1194. goto exit;
  1195. }
  1196. pcdev = kzalloc(sizeof(*pcdev), GFP_KERNEL);
  1197. if (!pcdev) {
  1198. dev_err(&pdev->dev, "Could not allocate pcdev\n");
  1199. err = -ENOMEM;
  1200. goto exit;
  1201. }
  1202. pcdev->clk = clk_get(&pdev->dev, NULL);
  1203. if (IS_ERR(pcdev->clk)) {
  1204. err = PTR_ERR(pcdev->clk);
  1205. goto exit_kfree;
  1206. }
  1207. dev_set_drvdata(&pdev->dev, pcdev);
  1208. pcdev->res = res;
  1209. pcdev->pdata = pdev->dev.platform_data;
  1210. pcdev->platform_flags = pcdev->pdata->flags;
  1211. if (!(pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 |
  1212. PXA_CAMERA_DATAWIDTH_9 | PXA_CAMERA_DATAWIDTH_10))) {
  1213. /* Platform hasn't set available data widths. This is bad.
  1214. * Warn and use a default. */
  1215. dev_warn(&pdev->dev, "WARNING! Platform hasn't set available "
  1216. "data widths, using default 10 bit\n");
  1217. pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10;
  1218. }
  1219. pcdev->mclk = pcdev->pdata->mclk_10khz * 10000;
  1220. if (!pcdev->mclk) {
  1221. dev_warn(&pdev->dev,
  1222. "mclk == 0! Please, fix your platform data. "
  1223. "Using default 20MHz\n");
  1224. pcdev->mclk = 20000000;
  1225. }
  1226. pcdev->dev = &pdev->dev;
  1227. pcdev->mclk_divisor = mclk_get_divisor(pcdev);
  1228. INIT_LIST_HEAD(&pcdev->capture);
  1229. spin_lock_init(&pcdev->lock);
  1230. /*
  1231. * Request the regions.
  1232. */
  1233. if (!request_mem_region(res->start, res->end - res->start + 1,
  1234. PXA_CAM_DRV_NAME)) {
  1235. err = -EBUSY;
  1236. goto exit_clk;
  1237. }
  1238. base = ioremap(res->start, res->end - res->start + 1);
  1239. if (!base) {
  1240. err = -ENOMEM;
  1241. goto exit_release;
  1242. }
  1243. pcdev->irq = irq;
  1244. pcdev->base = base;
  1245. /* request dma */
  1246. err = pxa_request_dma("CI_Y", DMA_PRIO_HIGH,
  1247. pxa_camera_dma_irq_y, pcdev);
  1248. if (err < 0) {
  1249. dev_err(pcdev->dev, "Can't request DMA for Y\n");
  1250. goto exit_iounmap;
  1251. }
  1252. pcdev->dma_chans[0] = err;
  1253. dev_dbg(pcdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]);
  1254. err = pxa_request_dma("CI_U", DMA_PRIO_HIGH,
  1255. pxa_camera_dma_irq_u, pcdev);
  1256. if (err < 0) {
  1257. dev_err(pcdev->dev, "Can't request DMA for U\n");
  1258. goto exit_free_dma_y;
  1259. }
  1260. pcdev->dma_chans[1] = err;
  1261. dev_dbg(pcdev->dev, "got DMA channel (U) %d\n", pcdev->dma_chans[1]);
  1262. err = pxa_request_dma("CI_V", DMA_PRIO_HIGH,
  1263. pxa_camera_dma_irq_v, pcdev);
  1264. if (err < 0) {
  1265. dev_err(pcdev->dev, "Can't request DMA for V\n");
  1266. goto exit_free_dma_u;
  1267. }
  1268. pcdev->dma_chans[2] = err;
  1269. dev_dbg(pcdev->dev, "got DMA channel (V) %d\n", pcdev->dma_chans[2]);
  1270. DRCMR(68) = pcdev->dma_chans[0] | DRCMR_MAPVLD;
  1271. DRCMR(69) = pcdev->dma_chans[1] | DRCMR_MAPVLD;
  1272. DRCMR(70) = pcdev->dma_chans[2] | DRCMR_MAPVLD;
  1273. /* request irq */
  1274. err = request_irq(pcdev->irq, pxa_camera_irq, 0, PXA_CAM_DRV_NAME,
  1275. pcdev);
  1276. if (err) {
  1277. dev_err(pcdev->dev, "Camera interrupt register failed \n");
  1278. goto exit_free_dma;
  1279. }
  1280. pxa_soc_camera_host.priv = pcdev;
  1281. pxa_soc_camera_host.dev.parent = &pdev->dev;
  1282. pxa_soc_camera_host.nr = pdev->id;
  1283. err = soc_camera_host_register(&pxa_soc_camera_host);
  1284. if (err)
  1285. goto exit_free_irq;
  1286. return 0;
  1287. exit_free_irq:
  1288. free_irq(pcdev->irq, pcdev);
  1289. exit_free_dma:
  1290. pxa_free_dma(pcdev->dma_chans[2]);
  1291. exit_free_dma_u:
  1292. pxa_free_dma(pcdev->dma_chans[1]);
  1293. exit_free_dma_y:
  1294. pxa_free_dma(pcdev->dma_chans[0]);
  1295. exit_iounmap:
  1296. iounmap(base);
  1297. exit_release:
  1298. release_mem_region(res->start, res->end - res->start + 1);
  1299. exit_clk:
  1300. clk_put(pcdev->clk);
  1301. exit_kfree:
  1302. kfree(pcdev);
  1303. exit:
  1304. return err;
  1305. }
  1306. static int __devexit pxa_camera_remove(struct platform_device *pdev)
  1307. {
  1308. struct pxa_camera_dev *pcdev = platform_get_drvdata(pdev);
  1309. struct resource *res;
  1310. clk_put(pcdev->clk);
  1311. pxa_free_dma(pcdev->dma_chans[0]);
  1312. pxa_free_dma(pcdev->dma_chans[1]);
  1313. pxa_free_dma(pcdev->dma_chans[2]);
  1314. free_irq(pcdev->irq, pcdev);
  1315. soc_camera_host_unregister(&pxa_soc_camera_host);
  1316. iounmap(pcdev->base);
  1317. res = pcdev->res;
  1318. release_mem_region(res->start, res->end - res->start + 1);
  1319. kfree(pcdev);
  1320. dev_info(&pdev->dev, "PXA Camera driver unloaded\n");
  1321. return 0;
  1322. }
  1323. static struct platform_driver pxa_camera_driver = {
  1324. .driver = {
  1325. .name = PXA_CAM_DRV_NAME,
  1326. },
  1327. .probe = pxa_camera_probe,
  1328. .remove = __exit_p(pxa_camera_remove),
  1329. };
  1330. static int __devinit pxa_camera_init(void)
  1331. {
  1332. return platform_driver_register(&pxa_camera_driver);
  1333. }
  1334. static void __exit pxa_camera_exit(void)
  1335. {
  1336. platform_driver_unregister(&pxa_camera_driver);
  1337. }
  1338. module_init(pxa_camera_init);
  1339. module_exit(pxa_camera_exit);
  1340. MODULE_DESCRIPTION("PXA27x SoC Camera Host driver");
  1341. MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>");
  1342. MODULE_LICENSE("GPL");