V4L2: soc_camera: Renesas R-Car VIN driver
Subsystems (3)
PATCH v7 1/1 V4L2: soc_camera: Renesas R-Car VIN driver
From: Vladimir Barinov <[email protected]>
Add Renesas R-Car VIN (Video In) V4L2 driver.
Based on the patch by Phil Edworthy <[email protected]>.
[Sergei: removed deprecated IRQF_DISABLED flag, reordered/renamed 'enum chip_id' values, reordered rcar_vin_id_table[] entries, removed senseless parens from to_buf_list() macro, used ALIGN() macro in rcar_vin_setup(), added {} to the *if* statement and used 'bool' values instead of 0/1 where necessary, removed unused macros, done some reformatting and clarified some comments.]
---
This patch is against the 'media_tree.git' repo.
It requires two following patches from Guennadi Liakhovetski:
https://patchwork.linuxtv.org/patch/18209/
https://patchwork.linuxtv.org/patch/18210/
Changes since version 6:
- sorted #include's alphabetically once again;
- BUG() on invalid format in rcar_vin_setup();
- used 'icd->sizeimage' instead of frame size calculation;
- moved WARN_ON() into the *if* condition and removed setting 'vb' to NULL in rcar_vin_remove_device();
- fixed 'packing' and 'layout' field values for 'fourcc' V4L2_PIX_FMT_NV16 in rcar_vin_formats[];
- made result handling logic more accurate in case subdevice does not support cropping;
- fixed scaling capability for pass-through pixel formats;
- resolved reject in the Makefile, refreshed the patch.
Changes since version 5:
- handled subdevice's inability to support cropping;
- set the field format depending on a video standard.
Changes since version 4:
- added "select SOC_CAMERA_SCALE_CROP" to Kconfig entry;
- added #include "soc_scale_crop.h", made use of the functions declared there instead of the analogous functions originally copied from the SH-Mobile CEU driver now that they have been placed in a module of their own, removing now unused private functions.
Changes since version 3:
- removed the driver's dependency on R-Car M1A/H1 SoCs from Kconfig;
- made the driver aware of the differences between R-Car E1/M1/H1 SoCs by having different platform device IDs for different SoCs, introcduced 'enum chips_id' to be used as the 'driver_data' field of 'struct platform_device_id' and then copied to the 'chip' field of 'struct rcar_vin_priv';
- sorted #include's alphabetically, added a number of #includes <media/v4l2-*>;
- removed the 'data_through' field of the 'struct rcar_vin_priv' and the pass- through logic from set_fmt() method;
- simplified is_continuous_transfer(), used it where applicable;
- removed senseless parens from to_buf_list() macro;
- removed the 'code' field from the 'struct rcar_vin_cam';
- largely rewrote the queue_setup() method;
- removed 'input_is_yuv' variable from rcar_vin_setup(), made 'progressive' and 'output_is_yuv' variables 'bool', and made setting VnDMR.EXRGB bit only happen on R-Car E1/H1 there;
- made use of ALIGN() macro in rcar_vin_setup() and rcar_vin_set_rect();
- fixed missing {} on one branch of the *if* statement in several places, added {} to the *if* statement where necessary;
- stopped saving/restoring flags when grabbing/dropping a spinlock in the buf_queue() and buf_cleanup() methods;
- made 'dsize' variable calculation depend on R-Car E1 in rcar_vin_set_rect()
- fix the continuous capturing to stop when there is no buffer to be set into the VnMBm registers in rcar_vin_irq();
- replaced BUG_ON() with WARN_ON() and *return* in the remove() method, also replaced pm_runtime_put_sync() with pm_runtime_put() there;
- removed size_dst() and calc_scale() as the calls to calc_scale() were also removed from the set_fmt() method;
- removed the VnMC register value check from capture_restore();
- removed 'cfg' variable initializers from set_bus_param() method and rcar_vin_try_bus_param();
- added bus width check to rcar_vin_try_bus_param();
- removed V4L2_PIX_FMT_YUYV format from rcar_vin_formats[], initialize 'layout' field of every element in this table;
- changed dev_err() call and *return* -EINVAL to dev_warn() and *return* 0 in the get_formats() method,
- added rcar_vin_packing_supported() and started handling pass-through mode in the get_formats() method;
- constified the parameters of is_smaller() and is_inside();
- redid the scaling logic so that it can't scale RGB32 data on R-Car E1 in the set_fmt() method, also stopped assigning to 'cam->code' there;
- started selecting the current format if soc_camera_xlate_by_fourcc() call failed in the try_fmt() method, also started letting 'soc-camera' calculate bytes-per-line and image size there;
- removed pm_runtime_resume() call from the driver's probe() method
- added setting of the 'timestamp_type' field to the init_videobuf2() method.
Changes since version 2:
- replaced Cyrillic characters in comments with the proper Latinic ones.
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 | 8 drivers/media/platform/soc_camera/Makefile | 1 drivers/media/platform/soc_camera/rcar_vin.c | 1470 +++++++++++++++++++++++++++ include/linux/platform_data/camera-rcar.h | 25 4 files changed, 1504 insertions(+)
drivers/media/platform/soc_camera/Kconfig +8 -0
@@ -44,6 +44,14 @@ 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 + select VIDEOBUF2_DMA_CONTIG + select SOC_CAMERA_SCALE_CROP + ---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
drivers/media/platform/soc_camera/Makefile +1 -0
@@ -14,3 +14,4 @@ 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
drivers/media/platform/soc_camera/rcar_vin.c new file +1470 -0
1,470 lines not on this page · raw message
include/linux/platform_data/camera-rcar.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Platform data for Renesas R-Car VIN soc-camera driver +* +* Copyright (C) 2011-2013 Renesas Solutions Corp. +* Copyright (C) 2013 Cogent Embedded, Inc., <[email protected]> +* +* 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. +*/ + +#ifndef __CAMERA_RCAR_H_ +#define __CAMERA_RCAR_H_ + +#define RCAR_VIN_HSYNC_ACTIVE_LOW (1 << 0) +#define RCAR_VIN_VSYNC_ACTIVE_LOW (1 << 1) +#define RCAR_VIN_BT601 (1 << 2) +#define RCAR_VIN_BT656 (1 << 3) + +struct rcar_vin_platform_data { +unsigned int flags; +}; + +#endif /* __CAMERA_RCAR_H_ */
Hi Sergei
Quoted 6 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add Renesas R-Car VIN (Video In) V4L2 driver.
Based on the patch by Phil Edworthy <[email protected]>.
Quoted 7 lines
Signed-off-by Vladimir Barinov <[email protected]>[Sergei: removed deprecated
IRQF_DISABLEDflag, reordered/renamed 'enumchip_id' values, reordered rcar_vin_id_table[] entries, removed senseless parens fromto_buf_list()macro, usedALIGN()macro inrcar_vin_setup(), added {} to the *if* statement and used 'bool' values instead of 0/1 where necessary, removed unused macros, done some reformatting and clarified some comments.]Signed-off-by Sergei Shtylyov <[email protected]>
Reviewing this iteration of the patch is still on my todo, in the meantime you might verify whether it works on top of the for-3.11-3 branch of my
http://git.linuxtv.org/gliakhovetski/v4l-dvb.git
git-tree, or "next" after it's been pulled by Mauro and pushed upstream. With that branch you shouldn't need any additional patches andy more.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
Hi Guennadi,
Quoted 20 lines · Guennadi Liakhovetski
Hi Sergei
Quoted 6 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add Renesas R-Car VIN (Video In) V4L2 driver.
Based on the patch by Phil Edworthy <[email protected]>.
Quoted 8 lines
Signed-off-by Vladimir Barinov <[email protected]>[Sergei: removed deprecated
IRQF_DISABLEDflag, reordered/renamed 'enumchip_id' values, reordered rcar_vin_id_table[] entries, removed senseless parens fromto_buf_list()macro, usedALIGN()macro inrcar_vin_setup(), added {} to the *if* statement and used 'bool' values instead of 0/1 where necessary, removed unused macros, done some reformatting and clarified some comments.]Signed-off-by Sergei Shtylyov <[email protected]>
Quoted 8 lines
Reviewing this iteration of the patch is still on my todo, in the meantime you might verify whether it works on top of the for-3.11-3 branch of my
http://git.linuxtv.org/gliakhovetski/v4l-dvb.git
git-tree, or "next" after it's been pulled by Mauro and pushed upstream. With that branch you shouldn't need any additional patches andy more.
Actually we need to apply/merge more patches here that enables VIN support on separate platform (like pinctrl/clock/setup/) :)
Despite of above the rcar_vin driver works fine on Marzen board in v4l-dvb.git after adding soc_camera_host_ops clock_start/clock_stop.
Regards,
Vladimir
Hello.
Quoted 28 lines · Vladimir Barinov
Quoted 22 lines
Quoted 16 lines
From: Vladimir Barinov <[email protected]>
Add Renesas R-Car VIN (Video In) V4L2 driver.
Based on the patch by Phil Edworthy <[email protected]>.
Signed-off-by Vladimir Barinov <[email protected]>[Sergei: removed deprecated
IRQF_DISABLEDflag, reordered/renamed 'enumchip_id'
values, reordered rcar_vin_id_table[] entries, removed senseless parens fromto_buf_list()macro, usedALIGN()macro inrcar_vin_setup(), added {} to the
*if* statement and used 'bool' values instead of 0/1 where necessary, removed
unused macros, done some reformatting and clarified some comments.]Quoted 1 line
Signed-off-by Sergei Shtylyov <[email protected]>Reviewing this iteration of the patch is still on my todo, in the meantime you might verify whether it works on top of the for-3.11-3 branch of my
Quoted 5 lines
http://git.linuxtv.org/gliakhovetski/v4l-dvb.git
git-tree, or "next" after it's been pulled by Mauro and pushed upstream. With that branch you shouldn't need any additional patches andy more.
Quoted 5 lines
Actually we need to apply/merge more patches here that enables VIN support on separate platform (like pinctrl/clock/setup/) :)
Despite of above the
rcar_vindriver works fine on Marzen board in v4l-dvb.git after addingsoc_camera_host_opsclock_start/clock_stop.
Guennadi, does that mean that we should rebase the driver to the
branch that you've named now?
Quoted 2 lines
Regards,
Vladimir
WBR, Sergei
Hi Sergei
Quoted 32 lines · Sergei Shtylyov
Hello.
Quoted 27 lines · Vladimir Barinov
Quoted 27 lines
Quoted 16 lines
From: Vladimir Barinov <[email protected]>
Add Renesas R-Car VIN (Video In) V4L2 driver.
Based on the patch by Phil Edworthy <[email protected]>.
Signed-off-by Vladimir Barinov <[email protected]>[Sergei: removed deprecated
IRQF_DISABLEDflag, reordered/renamed 'enumchip_id'
values, reordered rcar_vin_id_table[] entries, removed senseless parens fromto_buf_list()macro, usedALIGN()macro inrcar_vin_setup(), added {} to the
*if* statement and used 'bool' values instead of 0/1 where necessary, removed
unused macros, done some reformatting and clarified some comments.]Quoted 1 line
Signed-off-by Sergei Shtylyov <[email protected]>Reviewing this iteration of the patch is still on my todo, in the meantime you might verify whether it works on top of the for-3.11-3 branch of my
http://git.linuxtv.org/gliakhovetski/v4l-dvb.git
git-tree, or "next" after it's been pulled by Mauro and pushed upstream. With that branch you shouldn't need any additional patches andy more.
Quoted 8 lines
Quoted 5 lines
Actually we need to apply/merge more patches here that enables VIN support on separate platform (like pinctrl/clock/setup/) :)
Despite of above the
rcar_vindriver works fine on Marzen board in v4l-dvb.git after addingsoc_camera_host_opsclock_start/clock_stop.Guennadi, does that mean that we should rebase the driver to the branch
that you've named now?
IIUC, your last couple of versions were already developed on top of v4l2-clk + v4l2-asybc + soc_scale_crop patches, right? But those patches were out of tree, and thus unstable. Whereas now they've hit Mauro's tree at git.linuxtv.org and are about to be pulled into "next." So, you don't need anymore to apply any external patches, you will be able to just develop on top of "next." I presume, this should make your work easier, not harder. Just please make sure to double-check your stack on top of "next" to make sure it still works. And let's try to get your driver ready for 3.12.
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
Hi Guennadi,
Quoted 48 lines · Guennadi Liakhovetski
Hi Sergei
Quoted 33 lines · Sergei Shtylyov
Hello.
Quoted 28 lines · Vladimir Barinov
Quoted 28 lines
Quoted 16 lines
From: Vladimir Barinov <[email protected]>
Add Renesas R-Car VIN (Video In) V4L2 driver.
Based on the patch by Phil Edworthy <[email protected]>.
Signed-off-by Vladimir Barinov <[email protected]>[Sergei: removed deprecated
IRQF_DISABLEDflag, reordered/renamed 'enumchip_id'
values, reordered rcar_vin_id_table[] entries, removed senseless parens fromto_buf_list()macro, usedALIGN()macro inrcar_vin_setup(), added {} to the
*if* statement and used 'bool' values instead of 0/1 where necessary, removed
unused macros, done some reformatting and clarified some comments.]Quoted 2 lines
Signed-off-by Sergei Shtylyov <[email protected]>Reviewing this iteration of the patch is still on my todo, in the meantime you might verify whether it works on top of the for-3.11-3 branch of my
http://git.linuxtv.org/gliakhovetski/v4l-dvb.git
git-tree, or "next" after it's been pulled by Mauro and pushed upstream. With that branch you shouldn't need any additional patches andy more.
Quoted 9 lines
Quoted 6 lines
Actually we need to apply/merge more patches here that enables VIN support on separate platform (like pinctrl/clock/setup/) :)
Despite of above the
rcar_vindriver works fine on Marzen board in v4l-dvb.git after addingsoc_camera_host_opsclock_start/clock_stop.Guennadi, does that mean that we should rebase the driver to the branch
that you've named now?
Quoted 7 lines
IIUC, your last couple of versions were already developed on top of v4l2-clk + v4l2-asybc +
soc_scale_croppatches, right? But those patches were out of tree, and thus unstable. Whereas now they've hit Mauro's tree at git.linuxtv.org and are about to be pulled into "next." So, you don't need anymore to apply any external patches, you will be able to just develop on top of "next." I presume, this should make your work easier,
Correct, I was meaning about clock/mux/setup patches against platform code (arch/arm/mash-shmobile)
Quoted 4 lines
not harder. Just please make sure to double-check your stack on top of "next" to make sure it still works. And let's try to get your driver ready for 3.12.
Ok
Regards,
Vladimir
Hello.
Quoted 31 lines · Guennadi Liakhovetski
Quoted 30 lines
Quoted 30 lines
Quoted 22 lines
Quoted 16 lines
From: Vladimir Barinov <[email protected]>
Add Renesas R-Car VIN (Video In) V4L2 driver.
Based on the patch by Phil Edworthy <[email protected]>.
Signed-off-by Vladimir Barinov <[email protected]>[Sergei: removed deprecated
IRQF_DISABLEDflag, reordered/renamed 'enumchip_id'
values, reordered rcar_vin_id_table[] entries, removed senseless parens fromto_buf_list()macro, usedALIGN()macro inrcar_vin_setup(), added {} to the
*if* statement and used 'bool' values instead of 0/1 where necessary, removed
unused macros, done some reformatting and clarified some comments.]Quoted 1 line
Signed-off-by Sergei Shtylyov <[email protected]>Reviewing this iteration of the patch is still on my todo, in the meantime you might verify whether it works on top of the for-3.11-3 branch of my
Quoted 5 lines
http://git.linuxtv.org/gliakhovetski/v4l-dvb.git
git-tree, or "next" after it's been pulled by Mauro and pushed upstream. With that branch you shouldn't need any additional patches andy more.
Actually we need to apply/merge more patches here that enables VIN support on separate platform (like pinctrl/clock/setup/) :)
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Despite of above the
rcar_vindriver works fine on Marzen board in v4l-dvb.git after addingsoc_camera_host_opsclock_start/clock_stop.Guennadi, does that mean that we should rebase the driver to the branch
that you've named now?IIUC, your last couple of versions were already developed on top of v4l2-clk + v4l2-asybc +
soc_scale_croppatches, right?
No, I think only atop of the latter one.
Quoted 7 lines
But those patches
were out of tree, and thus unstable. Whereas now they've hit Mauro's tree at git.linuxtv.org and are about to be pulled into "next." So, you don't need anymore to apply any external patches, you will be able to just develop on top of "next." I presume, this should make your work easier, not harder. Just please make sure to double-check your stack on top of "next" to make sure it still works.
OK.
Quoted 1 line
And let's try to get your driver ready for 3.12.
Sigh, another couple months probably mean nothing for the media
tree, but it may be disastrous for Renesas' customers which use the LTSI tree...
Quoted 2 lines
Thanks
Guennadi
WBR, Sergei
Hi Guennadi,
Quoted 37 lines · Vladimir Barinov
Hi Guennadi,
Quoted 28 lines · Guennadi Liakhovetski
Hi Sergei
Quoted 16 lines · Sergei Shtylyov
From: Vladimir Barinov <[email protected]>
Add Renesas R-Car VIN (Video In) V4L2 driver.
Based on the patch by Phil Edworthy <[email protected]>.
Signed-off-by Vladimir Barinov <[email protected]>[Sergei: removed deprecated
IRQF_DISABLEDflag, reordered/renamed 'enumchip_id'
values, reordered rcar_vin_id_table[] entries, removed senseless parens fromto_buf_list()macro, usedALIGN()macro inrcar_vin_setup(), added {} to the
*if* statement and used 'bool' values instead of 0/1 where necessary, removed
unused macros, done some reformatting and clarified some comments.]Quoted 2 lines
Signed-off-by Sergei Shtylyov <[email protected]>Reviewing this iteration of the patch is still on my todo, in the meantime you might verify whether it works on top of the for-3.11-3 branch of my
Quoted 6 lines
http://git.linuxtv.org/gliakhovetski/v4l-dvb.git
git-tree, or "next" after it's been pulled by Mauro and pushed upstream. With that branch you shouldn't need any additional patches andy more.
Quoted 5 lines
Actually we need to apply/merge more patches here that enables VIN support on separate platform (like pinctrl/clock/setup/) :)
Despite of above the
rcar_vindriver works fine on Marzen board in v4l-dvb.git after addingsoc_camera_host_opsclock_start/clock_stop.
A little clarification here.
I have been adding empty clock_start/clock_stop callbacks to rcar_vin driver since for my setup "rcar_vin + adv7180" the icd->clk is NULL.
Regards,
Vladimir