Re: [PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
On Tue, 30 Apr 2013, Vladimir Barinov wrote: [snip] > > > > +static int rcar_vin_init_videobuf2(struct vb2_queue *vq, > > > > + struct soc_camera_device *icd) > > > > +{ > > > > +vq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; > > > > +vq->io_modes = VB2_MMAP | VB2_USERPTR; > > > > +vq->drv_priv = icd; > > > > +vq->ops = &rcar_vin_vb2_ops; > > > > +vq->mem_ops = &vb2_dma_contig_memops; > > > > +vq->buf_struct_size = sizeof(struct rcar_vin_buffer); > > > > > Please, add > > > > > vq->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; > > > There is not such field in "struct vb2_queue". Please, look at the current kernel, e.g. the "next" tree, within days this will be in Linus' tree too. Mainline submissions should always be developed against the newest kernel version. Thanks Guennadi --- Guennadi Liakhovetski, Ph.D. Freelance Open-Source Software Developer http://www.open-technology.de/ -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
Hi, Guennadi, Thank you for the review! Sergei Shtylyov wrote: I also strongly suspent some #include headers are missing above. Hm, I wonder which. I'm certainly not V4L2 expert... added following: #include #include #include #include #include +alloc_ctxs[0] = priv->alloc_ctx; + +if (!vq->num_buffers) +priv->sequence = 0; + +if (!*count) +*count = 2; +priv->vb_count = *count; + +*num_planes = 1; + +/* Number of hardware slots */ +if (priv->vb_count > MAX_BUFFER_NUM) +priv->nr_hw_slots = MAX_BUFFER_NUM; +else +priv->nr_hw_slots = 1; Is this really correct: with up to 3 buffers only one HW slot is used? Probably not. After replacing (priv->vb_count > MAX_BUFFER_NUM) with is_continuous_transfer(priv) the logic becomes clear. +break; +default: +vnmc = VNMC_IM_ODD; +break; +} + +/* input interface */ +switch (icd->current_fmt->code) { +case V4L2_MBUS_FMT_YUYV8_1X16: +/* BT.601/BT.1358 16bit YCbCr422 */ +vnmc |= VNMC_INF_YUV16; +input_is_yuv = 1; +break; +case V4L2_MBUS_FMT_YUYV8_2X8: +input_is_yuv = 1; +/* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */ +vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ? +VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601; Let's clarify this. By BT.656 you mean embedded synchronisation patterns, right? In that case HSYNC and VSYNC signals aren't used. Probably so, at least I know for sure HSYNC/VSYNC aren't used. Yes, it is. BT.656 uses embedded synchronization and HSYNC/VSYNC are not used for this type of interface. The BT.601 is a so-called by soc-camera layer MBUS_PARALLEL. But in your .set_bus_param() method you only support V4L2_MBUS_PARALLEL and not V4L2_MBUS_BT656. And what do you call BT601? A bus with sync signals used? Yeah, judging from the manual, HSYNC, VSYNC, FIELD are used in BT.601. The name ITUR BT601 YCbCr that comes from specification is a MBUS_PARALLEL name per soc-camera layer naming. The BT601 is expected to use h/w sync signals. I've removed the pre initialization of v4l2_mbus_config .type filed in favour of getting it from camera/decoder subdevice. Thx for pointing to this. +} +} +spin_unlock_irq(&priv->lock); + +pm_runtime_put_sync(ici->v4l2_dev.dev); Do you really need the _sync version above? I'm not runtime PM expert, to be honest... replaced with pm_runtime_put(). thx for pointing to this. +static u16 calc_scale(unsigned int src, unsigned int *dst) +{ +u16 scale; + +if (src == *dst) +return 0; + +scale = (src * 4096 / *dst) & ~7; + +while (scale > 4096 && size_dst(src, scale) < *dst) +scale -= 8; + +*dst = size_dst(src, scale); + +return scale; return value of this function is unused by the caller. Generally, your use of these two functions is different than on CEU, you might want to get rid of them completely. I'd prefer to leave this function and provide fixes after scaling is fully tested. +/* Set Start/End Pixel/Line Pre-Clip */ +iowrite32(left_offset << dsize, priv->base + VNSPPRC_REG); +iowrite32((left_offset + cam->width - 1) << dsize, + priv->base + VNEPPRC_REG); Do you have to shift for all 32-bit formats, not only for RGB32? I understand this is related to the fact, that you don't support pass-through... At least the manual says to program an even number to VnSPPrC... The driver explicitly says that V4L2_PIX_FMT_RGB32 is the only 32bit format supported. +static void capture_stop_preserve(struct rcar_vin_priv *priv, u32 *vnmc) +{ +*vnmc = ioread32(priv->base + VNMC_REG); +/* module disable */ +iowrite32(*vnmc & ~VNMC_ME, priv->base + VNMC_REG); +} + +static void capture_restore(struct rcar_vin_priv *priv, u32 vnmc) +{ +unsigned long timeout = jiffies + 10 * HZ; + +if (!(vnmc & ~VNMC_ME)) +/* Nothing to restore */ +return; And you don't have to wait for a frame end? If the module wasn't active, there's probably no point... however, let's defer it to Vladimir. Right. Thx for catching this. +}, +{ +.fourcc= V4L2_PIX_FMT_YUYV, +.name= "YUYV", +.bits_per_sample= 16, +.packing= SOC_MBUS_PACKING_NONE, +.order= SOC_MBUS_ORDER_LE, This conversion block is identical to the respective one in soc_mediabus.c, which suggests to me, that no conversion is taking place here. Then this mode should be usable for generic 8- or 16-bit pass-through? Let's defer this question to Vladimir. Will add pass-through. Thank you. +switch (code) { +case V4L2_MBUS_FMT_YUYV8_1X16: +case V4L2_MBUS_FMT_YUYV8_2X8: +if (cam->extra_fmt) +break; + +/* Add all our formats that can be generated by VIN */ +cam->extra_fmt = rcar_vin_formats; + +
Re: [PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
Hello. On 29-04-2013 11:23, Guennadi Liakhovetski wrote: send these patches patchwork.linuxtv.org Thanks, I totally forgot about this one. WBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
On Sun, 28 Apr 2013, Sergei Shtylyov wrote: > send these patches patchwork.linuxtv.org -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
Hello. On 25-04-2013 18:20, Guennadi Liakhovetski wrote: Hi Sergei Thanks for the patch. It's a collective work, my role has been the least one, mostly a reviewer. :-) From: Vladimir Barinov Add Renesas R-Car VIN (Video In) V4L2 driver. Based on the patch by Phil Edworthy . Signed-off-by: Vladimir Barinov [Sergei: removed deprecated IRQF_DISABLED flag.] Signed-off-by: Sergei Shtylyov [...] Index: renesas/drivers/media/platform/soc_camera/rcar_vin.c === --- /dev/null +++ renesas/drivers/media/platform/soc_camera/rcar_vin.c @@ -0,0 +1,1784 @@ [...] +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include I always suggest to sort headers alphabetically, then it is easier to avoid duplicates and adding new ones goes to "random" places in the list, instead of piling up at the bottom, reducing the chance of a merge conflict. OK, fair enough. I also strongly suspent some #include headers are missing above. Hm, I wonder which. I'm certainly not V4L2 expert... [...] +#define is_continuous_transfer(priv) (priv->vb_count > MAX_BUFFER_NUM ? \ +true : false) simpler: +#define is_continuous_transfer(priv) (priv->vb_count > MAX_BUFFER_NUM) Yes, I should have said the same to Vladimir. + +struct rcar_vin_buffer { + struct vb2_buffer vb; + struct list_headlist; +}; + +#define to_buf_list(vb2_buffer)(&(container_of((vb2_buffer), \ + struct rcar_vin_buffer, \ + vb))->list) parenthesis around container_of() above don't make much sense. You can just drop them: +#define to_buf_list(vb2_buffer)(&container_of((vb2_buffer), \ + struct rcar_vin_buffer, \ + vb)->list) OK. +struct rcar_vin_cam { [...] + enum v4l2_mbus_pixelcodecode; You don't use the "code" field. Will remove, thanks. +/* + * .queue_setup() is called to check whether the driver can accept the + * requested number of buffers and to fill in plane sizes + * for the current frame format if required + */ +static int rcar_vin_videobuf_setup(struct vb2_queue *vq, + const struct v4l2_format *fmt, + unsigned int *count, + unsigned int *num_planes, + unsigned int sizes[], void *alloc_ctxs[]) +{ + struct soc_camera_device *icd = soc_camera_from_vb2q(vq); + struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + struct rcar_vin_priv *priv = ici->priv; + s32 bytes_per_line; + unsigned int height; + + if (fmt) { + const struct soc_camera_format_xlate *xlate; + + xlate = soc_camera_xlate_by_fourcc(icd, + fmt->fmt.pix.pixelformat); + if (!xlate) + return -EINVAL; + bytes_per_line = soc_mbus_bytes_per_line(fmt->fmt.pix.width, +xlate->host_fmt); + height = fmt->fmt.pix.height; + } else { + /* Called from VIDIOC_REQBUFS or in compatibility mode */ + bytes_per_line = soc_mbus_bytes_per_line(icd->user_width, + icd->current_fmt->host_fmt); + height = icd->user_height; In this case icd->sizeimage already contains the correct value. + } + if (bytes_per_line < 0) + return bytes_per_line; + + sizes[0] = bytes_per_line * height; This isn't right for planar formats, like NV16. Please, use soc_mbus_image_size(). See the CEU driver for an example. OK, will look... + alloc_ctxs[0] = priv->alloc_ctx; + + if (!vq->num_buffers) + priv->sequence = 0; + + if (!*count) + *count = 2; + priv->vb_count = *count; + + *num_planes = 1; + + /* Number of hardware slots */ + if (priv->vb_count > MAX_BUFFER_NUM) + priv->nr_hw_slots = MAX_BUFFER_NUM; + else + priv->nr_hw_slots = 1; Is this really correct: with up to 3 buffers only one HW slot is used? Probably not. +static void rcar_vin_setup(struct rcar_vin_priv *priv) +{ + struct soc_camera_device *icd = priv->icd; + struct rcar_vin_cam *cam = icd->host_priv; + u32 vnmc, dmr, interrupts; + int progressive = 0, input_is_yuv = 0, output_is_yuv = 0; All these variables can be bool. OK. + switch (priv->field) { [...] + case V4L2_FIELD_NONE: +
Re: [PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
Hi Sergei, On Fri, Apr 19, 2013 at 11:31 PM, Sergei Shtylyov wrote: > From: Vladimir Barinov > > Add Renesas R-Car VIN (Video In) V4L2 driver. > > Based on the patch by Phil Edworthy . > > Signed-off-by: Vladimir Barinov > [Sergei: removed deprecated IRQF_DISABLED flag.] > Signed-off-by: Sergei Shtylyov > > --- > Changes since the original posting: > - added IRQF_SHARED flag in devm_request_irq() call (since on R8A7778 VIN0/1 > share the same IRQ) and removed deprecated IRQF_DISABLED flag. > > drivers/media/platform/soc_camera/Kconfig|7 > drivers/media/platform/soc_camera/Makefile |1 > drivers/media/platform/soc_camera/rcar_vin.c | 1784 > +++ > include/linux/platform_data/camera-rcar.h| 25 > 4 files changed, 1817 insertions(+) > > Index: renesas/drivers/media/platform/soc_camera/Kconfig > === > --- renesas.orig/drivers/media/platform/soc_camera/Kconfig > +++ renesas/drivers/media/platform/soc_camera/Kconfig > @@ -45,6 +45,13 @@ config VIDEO_PXA27x > ---help--- > This is a v4l2 driver for the PXA27x Quick Capture Interface > > +config VIDEO_RCAR_VIN > + tristate "R-Car Video Input (VIN) support" > + depends on VIDEO_DEV && SOC_CAMERA && (ARCH_R8A7778 || ARCH_R8A7779) > + select VIDEOBUF2_DMA_CONTIG > + ---help--- > + This is a v4l2 driver for the R-Car VIN Interface Thanks for your work on this. I believe there are multiple SoCs containing VIN hardware, so limiting to r8a7778 and r8a7779 doesn't make sense to me. Actually, our other drivers do not have this kind of detailed dependency control. So based on that, would it be possible for you to change the above dependency to: depends on VIDEO_DEV && SOC_CAMERA Thanks, / magnus -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
Hi, From: Sergei Shtylyov Date: Tue, 23 Apr 2013 08:38:35 +0400 > On 04/23/2013 07:08 AM, Katsuya MATSUBARA wrote: > >>> From: Vladimir Barinov >>> (snip) >>> +/* Register offsets for R-Сar VIN */ >> Are you using a 2-byte character in the string 'R-Car'? > >Hm, you have surprised me: indeed KMail chose UTF-8 and, even worse, > quoted-printable encoding. I played some with the settings, let's see > what > will it do... > > [...] > >> >>> + >>> +/* Register bit fields for R-Сar VIN */ >> s/R-Сar/R-Car/ > > Sorry, I see no difference. :-) Replacing the UTF-8 character 'C'(0xd0 0xa1) in the two above comments in your patch with ASCII character 'C' (0x43) can solve the encoding issue. 0cf0 2b 2f 2a 20 52 65 67 69 73 74 65 72 20 6f 66 66 |+/* Register off| 0d00 73 65 74 73 20 66 6f 72 20 52 2d d0 a1 61 72 20 |sets for R-..ar | ^ 12a0 74 65 72 20 2a 2f 0a 2b 0a 2b 2f 2a 20 52 65 67 |ter */.+.+/* Reg| 12b0 69 73 74 65 72 20 62 69 74 20 66 69 65 6c 64 73 |ister bit fields| 12c0 20 66 6f 72 20 52 2d d0 a1 61 72 20 56 49 4e 20 | for R-..ar VIN | ^^ Thanks, --- Katsuya Matsubara / IGEL Co., Ltd ma...@igel.co.jp -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
Hello. On 04/23/2013 07:08 AM, Katsuya MATSUBARA wrote: Hi Sergei, Thanks for the patch. It's not mine. :-) From: Vladimir Barinov Add Renesas R-Car VIN (Video In) V4L2 driver. Based on the patch by Phil Edworthy . Signed-off-by: Vladimir Barinov [Sergei: removed deprecated IRQF_DISABLED flag.] Signed-off-by: Sergei Shtylyov [...] Index: renesas/drivers/media/platform/soc_camera/rcar_vin.c === --- /dev/null +++ renesas/drivers/media/platform/soc_camera/rcar_vin.c @@ -0,0 +1,1784 @@ +/* + * SoC-camera host driver for Renesas R-Car VIN unit + * + * Copyright (C) 2011-2013 Renesas Solutions Corp. + * Copyright (C) 2013 Cogent Embedded, Inc., + * + * Based on V4L2 Driver for SuperH Mobile CEU interface "sh_mobile_ceu_camera.c" + * + * Copyright (C) 2008 Magnus Damm + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define DRV_NAME "rcar_vin" + +/* Register offsets for R-Сar VIN */ Are you using a 2-byte character in the string 'R-Car'? Hm, you have surprised me: indeed KMail chose UTF-8 and, even worse, quoted-printable encoding. I played some with the settings, let's see what will it do... [...] + +/* Register bit fields for R-Сar VIN */ s/R-Сar/R-Car/ Sorry, I see no difference. :-) + +#define is_continuous_transfer(priv) (priv->vb_count > MAX_BUFFER_NUM ? \ +true : false) + [...] + + /* Number of hardware slots */ + if (priv->vb_count > MAX_BUFFER_NUM) You can use the is_continuous_transfer() macro here. You're right. [...] + + /* input interface */ + switch (icd->current_fmt->code) { + case V4L2_MBUS_FMT_YUYV8_1X16: + /* BT.601/BT.1358 16bit YCbCr422 */ + vnmc |= VNMC_INF_YUV16; + input_is_yuv = 1; + break; + case V4L2_MBUS_FMT_YUYV8_2X8: + input_is_yuv = 1; + /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */ + vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ? + VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601; + default: + break; + } Does this (first) implemenation unsupport RGB inputs yet though the h/w supports them? Yes, we have only tested BT.601/656 input. If so, 'is_input_yuv' could be useless since it must be set to 1 in any case. The *default* label doesn't set it, does it? + + /* output format */ + switch (icd->current_fmt->host_fmt->fourcc) { + case V4L2_PIX_FMT_NV16: + iowrite32(((cam->width * cam->height) + 0x7f) & ~0x7f, + priv->base + VNUVAOF_REG); + dmr = VNDMR_DTMD_YCSEP; + output_is_yuv = 1; + break; + case V4L2_PIX_FMT_YUYV: + dmr = VNDMR_BPSM; + output_is_yuv = 1; + break; + case V4L2_PIX_FMT_UYVY: + dmr = 0; + output_is_yuv = 1; + break; + case V4L2_PIX_FMT_RGB555X: + dmr = VNDMR_DTMD_ARGB1555; + break; + case V4L2_PIX_FMT_RGB565: + dmr = 0; + break; + case V4L2_PIX_FMT_RGB32: + dmr = VNDMR_EXRGB; + break; VIN in R8A7778(R-CarM1A) does not support the RGB32 output, but R8A7779(R-CarH1) and uPD35004(R-CarE1) ones support it. Indeed... + + if (!priv->request_to_stop) { + if (is_continuous_transfer(priv)) + slot = (ioread32(priv->base + VNMS_REG) & + VNMS_FBS_MASK) >> VNMS_FBS_SHIFT; + else + slot = 0; + + priv->queue_buf[slot]->v4l2_buf.field = priv->field; + priv->queue_buf[slot]->v4l2_buf.sequence = priv->sequence++; + do_gettimeofday(&priv->queue_buf[slot]->v4l2_buf.timestamp); + vb2_buffer_done(priv->queue_buf[slot], VB2_BUF_STATE_DONE); + priv->queue_buf[slot] = NULL; + + if (priv->state != STOPPING) + can_run = rcar_vin_fill_hw_slot(priv); + + if (hw_stopped || !can_run) + priv->state = STOPPED; The continuous capturing should require an explicit stop operation when there is no buffer to be set into the MBx register because the h/w can keep running even if no more buffers are supplied. Understood. I'll defer this to Vladimir though... +/* rect is guaranteed to not exceed the scaled camera rectangle */ +static int rcar_vin_set_rect(s
Re: [PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
Hi Sergei, Thanks for the patch. From: Sergei Shtylyov Date: Sat, 20 Apr 2013 02:31:31 +0400 > From: Vladimir Barinov > > Add Renesas R-Car VIN (Video In) V4L2 driver. > > Based on the patch by Phil Edworthy . > > Signed-off-by: Vladimir Barinov > [Sergei: removed deprecated IRQF_DISABLED flag.] > Signed-off-by: Sergei Shtylyov > > --- > Changes since the original posting: > - added IRQF_SHARED flag in devm_request_irq() call (since on R8A7778 VIN0/1 > share the same IRQ) and removed deprecated IRQF_DISABLED flag. > > drivers/media/platform/soc_camera/Kconfig|7 > drivers/media/platform/soc_camera/Makefile |1 > drivers/media/platform/soc_camera/rcar_vin.c | 1784 > +++ > include/linux/platform_data/camera-rcar.h| 25 > 4 files changed, 1817 insertions(+) > > Index: renesas/drivers/media/platform/soc_camera/Kconfig > === > --- renesas.orig/drivers/media/platform/soc_camera/Kconfig > +++ renesas/drivers/media/platform/soc_camera/Kconfig > @@ -45,6 +45,13 @@ config VIDEO_PXA27x > ---help--- > This is a v4l2 driver for the PXA27x Quick Capture Interface > > +config VIDEO_RCAR_VIN > + tristate "R-Car Video Input (VIN) support" > + depends on VIDEO_DEV && SOC_CAMERA && (ARCH_R8A7778 || ARCH_R8A7779) > + select VIDEOBUF2_DMA_CONTIG > + ---help--- > + This is a v4l2 driver for the R-Car VIN Interface > + > config VIDEO_SH_MOBILE_CSI2 > tristate "SuperH Mobile MIPI CSI-2 Interface driver" > depends on VIDEO_DEV && SOC_CAMERA && HAVE_CLK > Index: renesas/drivers/media/platform/soc_camera/Makefile > === > --- renesas.orig/drivers/media/platform/soc_camera/Makefile > +++ renesas/drivers/media/platform/soc_camera/Makefile > @@ -10,5 +10,6 @@ obj-$(CONFIG_VIDEO_OMAP1) += omap1_came > obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o > obj-$(CONFIG_VIDEO_SH_MOBILE_CEU)+= sh_mobile_ceu_camera.o > obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o > +obj-$(CONFIG_VIDEO_RCAR_VIN) += rcar_vin.o > > ccflags-y += -I$(srctree)/drivers/media/i2c/soc_camera > Index: renesas/drivers/media/platform/soc_camera/rcar_vin.c > === > --- /dev/null > +++ renesas/drivers/media/platform/soc_camera/rcar_vin.c > @@ -0,0 +1,1784 @@ > +/* > + * SoC-camera host driver for Renesas R-Car VIN unit > + * > + * Copyright (C) 2011-2013 Renesas Solutions Corp. > + * Copyright (C) 2013 Cogent Embedded, Inc., > + * > + * Based on V4L2 Driver for SuperH Mobile CEU interface > "sh_mobile_ceu_camera.c" > + * > + * Copyright (C) 2008 Magnus Damm > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License as published by the > + * Free Software Foundation; either version 2 of the License, or (at your > + * option) any later version. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > + > +#define DRV_NAME "rcar_vin" > + > +/* Register offsets for R-Сar VIN */ Are you using a 2-byte character in the string 'R-Car'? > +#define VNMC_REG 0x00/* Video n Main Control Register */ > +#define VNMS_REG 0x04/* Video n Module Status Register */ > +#define VNFC_REG 0x08/* Video n Frame Capture Register */ > +#define VNSLPRC_REG 0x0C/* Video n Start Line Pre-Clip Register */ > +#define VNELPRC_REG 0x10/* Video n End Line Pre-Clip Register */ > +#define VNSPPRC_REG 0x14/* Video n Start Pixel Pre-Clip Register */ > +#define VNEPPRC_REG 0x18/* Video n End Pixel Pre-Clip Register */ > +#define VNSLPOC_REG 0x1C/* Video n Start Line Post-Clip Register */ > +#define VNELPOC_REG 0x20/* Video n End Line Post-Clip Register */ > +#define VNSPPOC_REG 0x24/* Video n Start Pixel Post-Clip Register */ > +#define VNEPPOC_REG 0x28/* Video n End Pixel Post-Clip Register */ > +#define VNIS_REG 0x2C/* Video n Image Stride Register */ > +#define VNMB_REG(m) (0x30 + ((m) << 2)) /* Video n Memory Base m Register */ > +#define VNIE_REG 0x40/* Video n Interrupt Enable Register */ > +#define VNINTS_REG 0x44/* Video n Interrupt Status Register */ > +#define VNSI_REG 0x48/* Video n Scanline Interrupt Register */ > +#define VNMTC_REG0x4C/* Video n Memory Transfer Control Register */ > +#define VNYS_REG 0x50/* Video n Y Scale Register */ > +#define VNXS_REG 0x54/* Video n X Scale Register */ > +#define VNDMR_REG0x58/* Video n Data Mode Register */ > +#define VNDMR2_REG 0x5C/* Video n Data Mode Register 2 */ > +#define VNUVAOF_REG 0x60/* Video n UV Address Offset Register */ > + > +/* Register bit fields for R-Сar VIN */ s/R-Сar/R-Ca
[PATCH v2 1/4] V4L2: soc_camera: Renesas R-Car VIN driver
From: Vladimir Barinov Add Renesas R-Car VIN (Video In) V4L2 driver. Based on the patch by Phil Edworthy . Signed-off-by: Vladimir Barinov [Sergei: removed deprecated IRQF_DISABLED flag.] Signed-off-by: Sergei Shtylyov --- Changes since the original posting: - added IRQF_SHARED flag in devm_request_irq() call (since on R8A7778 VIN0/1 share the same IRQ) and removed deprecated IRQF_DISABLED flag. drivers/media/platform/soc_camera/Kconfig|7 drivers/media/platform/soc_camera/Makefile |1 drivers/media/platform/soc_camera/rcar_vin.c | 1784 +++ include/linux/platform_data/camera-rcar.h| 25 4 files changed, 1817 insertions(+) Index: renesas/drivers/media/platform/soc_camera/Kconfig === --- renesas.orig/drivers/media/platform/soc_camera/Kconfig +++ renesas/drivers/media/platform/soc_camera/Kconfig @@ -45,6 +45,13 @@ config VIDEO_PXA27x ---help--- This is a v4l2 driver for the PXA27x Quick Capture Interface +config VIDEO_RCAR_VIN + tristate "R-Car Video Input (VIN) support" + depends on VIDEO_DEV && SOC_CAMERA && (ARCH_R8A7778 || ARCH_R8A7779) + select VIDEOBUF2_DMA_CONTIG + ---help--- + This is a v4l2 driver for the R-Car VIN Interface + config VIDEO_SH_MOBILE_CSI2 tristate "SuperH Mobile MIPI CSI-2 Interface driver" depends on VIDEO_DEV && SOC_CAMERA && HAVE_CLK Index: renesas/drivers/media/platform/soc_camera/Makefile === --- renesas.orig/drivers/media/platform/soc_camera/Makefile +++ renesas/drivers/media/platform/soc_camera/Makefile @@ -10,5 +10,6 @@ obj-$(CONFIG_VIDEO_OMAP1) += omap1_came obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o obj-$(CONFIG_VIDEO_SH_MOBILE_CEU) += sh_mobile_ceu_camera.o obj-$(CONFIG_VIDEO_SH_MOBILE_CSI2) += sh_mobile_csi2.o +obj-$(CONFIG_VIDEO_RCAR_VIN) += rcar_vin.o ccflags-y += -I$(srctree)/drivers/media/i2c/soc_camera Index: renesas/drivers/media/platform/soc_camera/rcar_vin.c === --- /dev/null +++ renesas/drivers/media/platform/soc_camera/rcar_vin.c @@ -0,0 +1,1784 @@ +/* + * SoC-camera host driver for Renesas R-Car VIN unit + * + * Copyright (C) 2011-2013 Renesas Solutions Corp. + * Copyright (C) 2013 Cogent Embedded, Inc., + * + * Based on V4L2 Driver for SuperH Mobile CEU interface "sh_mobile_ceu_camera.c" + * + * Copyright (C) 2008 Magnus Damm + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define DRV_NAME "rcar_vin" + +/* Register offsets for R-Сar VIN */ +#define VNMC_REG 0x00/* Video n Main Control Register */ +#define VNMS_REG 0x04/* Video n Module Status Register */ +#define VNFC_REG 0x08/* Video n Frame Capture Register */ +#define VNSLPRC_REG0x0C/* Video n Start Line Pre-Clip Register */ +#define VNELPRC_REG0x10/* Video n End Line Pre-Clip Register */ +#define VNSPPRC_REG0x14/* Video n Start Pixel Pre-Clip Register */ +#define VNEPPRC_REG0x18/* Video n End Pixel Pre-Clip Register */ +#define VNSLPOC_REG0x1C/* Video n Start Line Post-Clip Register */ +#define VNELPOC_REG0x20/* Video n End Line Post-Clip Register */ +#define VNSPPOC_REG0x24/* Video n Start Pixel Post-Clip Register */ +#define VNEPPOC_REG0x28/* Video n End Pixel Post-Clip Register */ +#define VNIS_REG 0x2C/* Video n Image Stride Register */ +#define VNMB_REG(m)(0x30 + ((m) << 2)) /* Video n Memory Base m Register */ +#define VNIE_REG 0x40/* Video n Interrupt Enable Register */ +#define VNINTS_REG 0x44/* Video n Interrupt Status Register */ +#define VNSI_REG 0x48/* Video n Scanline Interrupt Register */ +#define VNMTC_REG 0x4C/* Video n Memory Transfer Control Register */ +#define VNYS_REG 0x50/* Video n Y Scale Register */ +#define VNXS_REG 0x54/* Video n X Scale Register */ +#define VNDMR_REG 0x58/* Video n Data Mode Register */ +#define VNDMR2_REG 0x5C/* Video n Data Mode Register 2 */ +#define VNUVAOF_REG0x60/* Video n UV Address Offset Register */ + +/* Register bit fields for R-Сar VIN */ +/* Video n Main Control Register bits */ +#define VNMC_FOC (1 << 21) +#define VNMC_YCAL (1 << 19) +#define VNMC_INF_YUV8_BT656(0 << 16) +#define VNMC_INF_YUV8_BT601(1 << 16) +#define VNMC_INF_YUV16 (5 << 16) +#define VNMC_VUP (1 << 10) +#define VNMC_IM_ODD