Add support for the SDM845 Camera Subsystem
Subsystems (6)
v4 cover Add support for the SDM845 Camera Subsystem
This series implements support for the camera subsystem found in the SDM845 SOCs and the Titan 170 ISP. The support is partial in that it implements CSIPHY, CSID, and partial VFE support.
The Titan generation of the ISP diverges a fair amount from the design of the previous architecture generation, CAMSS. As a result some pretty invasive refactoring is done in this series. It also means that at this time we're unable to implement support for all of the IP blocks contained. This is due to a combination of legal considerations with respect to the IP and its owner Qualcomm and time & man hour constrains on the Linaro side.
The CSIPHY (CSI Physical Layer) & CSID (CSI Decoder) support is complete, but the VFE (Video Front End, which is referred to as IFE (Image Front End) in the Titan generation of ISPs) only has support for the RDI (Raw Dump Interface) which allows the raw output of the CSID to be written to memory.
The 2nd interface implemented in the VFE silicon is the PIX interface, and camss does not support it for this generation of ISPs. The reason for this is that the PIX interface is used for sending image data to the BPS (Bayer Processing Section) & IPE (Image Processing Engine), but both of these units are beyond the scope of enabling basic ISP functionality for the SDM845.
Since the Titan architecture generation diverges quite a bit from the CAMSS generation, a lot of pretty major refactoring is carried out in this series. Both the CSID & VFE core paths are made more general and hardware version specific parts are broken out. The CSIPHY didn't require quite as radical changes and therefore keeps its current form.
Tested on:
- Qcom RB3 / db845c + camera mezzanine, which is SDM845 based
- db410c + D3 Camera mezzanine, which is APQ8016 based
Branch:
- https://git.linaro.org/people/robert.foss/linux.git/log/?h=camss_sdm845_v1
- https://git.linaro.org/people/robert.foss/linux.git/log/?h=camss_sdm845_v2
- https://git.linaro.org/people/robert.foss/linux.git/log/?h=camss_sdm845_v3
Due to the dt-bindings supporting sdm660-camss, this series depends the sdm660 clock driver being upstreamed. I've linked this series below.
SDM630/660 Multimedia and GPU clock controllers
https://lkml.org/lkml/2020/9/26/166
Robert Foss (22):
media: camss: Fix vfe_isr_comp_done() documentation
media: camss: Fix vfe_isr comment typo
media: camss: Replace trace_printk() with dev_dbg()
media: camss: Add CAMSS_845 camss version
media: camss: Make ISPIF subdevice optional
media: camss: Refactor VFE HW version support
media: camss: Add support for VFE hardware version Titan 170
media: camss: Add missing format identifiers
media: camss: Refactor CSID HW version support
media: camss: Add support for CSID hardware version Titan 170
media: camss: Add support for CSIPHY hardware version Titan 170
media: camss: Remove per VFE power domain toggling
media: camss: Enable SDM845
dt-bindings: media: camss: Add qcom,msm8916-camss binding
dt-bindings: media: camss: Add qcom,msm8996-camss binding
dt-bindings: media: camss: Add qcom,sdm660-camss binding
dt-bindings: media: camss: Add qcom,sdm845-camss binding
MAINTAINERS: Change CAMSS documentation to use dtschema bindings
media: dt-bindings: media: Remove qcom,camss documentation
arm64: dts: sdm845: Add CAMSS ISP node
arm64: dts: sdm845-db845c: Configure regulators for camss node
arm64: dts: sdm845-db845c: Enable ov8856 sensor and connect to ISP
.../devicetree/bindings/media/qcom,camss.txt | 236 ---- .../bindings/media/qcom,msm8916-camss.yaml | 256 ++++ .../bindings/media/qcom,msm8996-camss.yaml | 387 ++++++ .../bindings/media/qcom,sdm660-camss.yaml | 398 ++++++ .../bindings/media/qcom,sdm845-camss.yaml | 370 ++++++ MAINTAINERS | 2 +- arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 23 +- arch/arm64/boot/dts/qcom/sdm845.dtsi | 135 ++ drivers/media/platform/qcom/camss/Makefile | 6 + .../platform/qcom/camss/camss-csid-170.c | 602 +++++++++ .../platform/qcom/camss/camss-csid-4-1.c | 338 +++++ .../platform/qcom/camss/camss-csid-4-7.c | 406 ++++++ .../media/platform/qcom/camss/camss-csid.c | 620 +-------- .../media/platform/qcom/camss/camss-csid.h | 178 ++- .../qcom/camss/camss-csiphy-3ph-1-0.c | 182 ++- .../media/platform/qcom/camss/camss-csiphy.c | 66 +- .../media/platform/qcom/camss/camss-ispif.c | 117 +- .../media/platform/qcom/camss/camss-ispif.h | 3 +- .../media/platform/qcom/camss/camss-vfe-170.c | 804 ++++++++++++ .../media/platform/qcom/camss/camss-vfe-4-1.c | 123 +- .../media/platform/qcom/camss/camss-vfe-4-7.c | 244 ++-- .../media/platform/qcom/camss/camss-vfe-4-8.c | 1164 +++++++++++++++++ .../platform/qcom/camss/camss-vfe-gen1.c | 763 +++++++++++ .../platform/qcom/camss/camss-vfe-gen1.h | 110 ++ drivers/media/platform/qcom/camss/camss-vfe.c | 840 +----------- drivers/media/platform/qcom/camss/camss-vfe.h | 118 +- .../media/platform/qcom/camss/camss-video.c | 100 ++ drivers/media/platform/qcom/camss/camss.c | 419 ++++-- drivers/media/platform/qcom/camss/camss.h | 17 +- 29 files changed, 6965 insertions(+), 2062 deletions(-) delete mode 100644 Documentation/devicetree/bindings/media/qcom,camss.txt create mode 100644 Documentation/devicetree/bindings/media/qcom,msm8916-camss.yaml create mode 100644 Documentation/devicetree/bindings/media/qcom,msm8996-camss.yaml create mode 100644 Documentation/devicetree/bindings/media/qcom,sdm660-camss.yaml create mode 100644 Documentation/devicetree/bindings/media/qcom,sdm845-camss.yaml create mode 100644 drivers/media/platform/qcom/camss/camss-csid-170.c create mode 100644 drivers/media/platform/qcom/camss/camss-csid-4-1.c create mode 100644 drivers/media/platform/qcom/camss/camss-csid-4-7.c create mode 100644 drivers/media/platform/qcom/camss/camss-vfe-170.c create mode 100644 drivers/media/platform/qcom/camss/camss-vfe-4-8.c create mode 100644 drivers/media/platform/qcom/camss/camss-vfe-gen1.c create mode 100644 drivers/media/platform/qcom/camss/camss-vfe-gen1.h
Signature · 1 line
2.27.0
PATCH v4 1/22 media: camss: Fix vfe_isr_comp_done() documentation
Function name is comment is wrong, and was changed to be the same as the actual function name.
The comment was changed to kerneldoc format.
---
Changes since v1
- Bjorn: Fix function doc name & use kerneldoc format
drivers/media/platform/qcom/camss/camss-vfe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe.c +2 -2
@@ -1076,8 +1076,8 @@ static void vfe_isr_wm_done(struct vfe_device *vfe, u8 wm)spin_unlock_irqrestore (&vfe->output_lock, flags); } -/* -* vfe_isr_wm_done - Process composite image done interrupt +/** +* vfe_isr_comp_done() - Process composite image done interrupt * @vfe: VFE Device * @comp: Composite image id */
Signature · 1 line
2.27.0
PATCH v4 2/22 media: camss: Fix vfe_isr comment typo
In reply to Robert FossComment refers to ISPIF, but this is incorrect. Only the VFE interrupts are handled by this function.
---
Changes since v1
- Bjorn: Add r-b
drivers/media/platform/qcom/camss/camss-vfe-4-1.c | 2 +- drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe-4-1.c +1 -1
@@ -922,7 +922,7 @@ static void vfe_violation_read(struct vfe_device *vfe) }/* -* vfe_isr - ISPIF module interrupt handler +* vfe_isr - VFE module interrupt handler * @irq: Interrupt line * @dev: VFE device *
drivers/media/platform/qcom/camss/camss-vfe-4-7.c +1 -1
@@ -1055,7 +1055,7 @@ static void vfe_violation_read(struct vfe_device *vfe) }/* -* vfe_isr - ISPIF module interrupt handler +* vfe_isr - VFE module interrupt handler * @irq: Interrupt line * @dev: VFE device *
Signature · 1 line
2.27.0
PATCH v4 3/22 media: camss: Replace trace_printk() with dev_dbg()
In reply to Robert Fosstrace_printk() should not be used in production code, since extra memory is used for special buffers whenever trace_puts() is used.
Replace it with dev_dbg() which provides all of the desired debugging functionality.
---
Changes since v3:
- Nicolas: Create this patch
drivers/media/platform/qcom/camss/camss-vfe-4-1.c | 5 +++-- drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe-4-1.c +3 -2
@@ -12,6 +12,7 @@#include <linux/io.h> #include <linux/iopoll.h> +#include "camss.h" #include "camss-vfe.h" #define VFE_0_HW_VERSION 0x000
@@ -936,8 +937,8 @@ static irqreturn_t vfe_isr(int irq, void *dev) vfe->ops->isr_read (vfe, &value0, &value1); -trace_printk ("VFE: status0 = 0x%08x, status1 = 0x%08x\n" , - value0, value1); +dev_dbg (vfe->camss->dev,"VFE: status0 = 0x%08x, status1 = 0x%08x\n" , + value0, value1);if (value0 &VFE_0_IRQ_STATUS_0_RESET_ACK ) vfe->isr_ops.reset_ack (vfe);
drivers/media/platform/qcom/camss/camss-vfe-4-7.c +3 -2
@@ -12,6 +12,7 @@#include <linux/io.h> #include <linux/iopoll.h> +#include "camss.h" #include "camss-vfe.h" #define VFE_0_HW_VERSION 0x000
@@ -1069,8 +1070,8 @@ static irqreturn_t vfe_isr(int irq, void *dev) vfe->ops->isr_read (vfe, &value0, &value1); -trace_printk ("VFE: status0 = 0x%08x, status1 = 0x%08x\n" , - value0, value1); +dev_dbg (vfe->camss->dev,"VFE: status0 = 0x%08x, status1 = 0x%08x\n" , + value0, value1);if (value0 &VFE_0_IRQ_STATUS_0_RESET_ACK ) vfe->isr_ops.reset_ack (vfe);
Signature · 1 line
2.27.0
Re: [PATCH v4 03/22] media: camss: Replace trace_printk() with dev_dbg()
Quoted 10 lines · Robert Foss
trace_printk()should not be used in production code, since extra memory is used for special buffers whenevertrace_puts()is used.Replace it with
dev_dbg()which provides all of the desired debugging functionality.Signed-off-by Robert Foss <[email protected]>Suggested-by Nicolas Boichat <[email protected]>
Thanks!
Quoted 59 lines
---
Changes since v3:
- Nicolas: Create this patchdrivers/media/platform/qcom/camss/camss-vfe-4-1.c | 5 +++-- drivers/media/platform/qcom/camss/camss-vfe-4-7.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)drivers/media/platform/qcom/camss/camss-vfe-4-1.c +3
-2@@ -12,6 +12,7 @@#include <linux/io.h> #include <linux/iopoll.h> +#include "camss.h" #include "camss-vfe.h" #define VFE_0_HW_VERSION 0x000@@ -936,8 +937,8 @@ static irqreturn_t vfe_isr(int irq, void *dev) vfe->ops->isr_read (vfe, &value0, &value1); -trace_printk ("VFE: status0 = 0x%08x, status1 = 0x%08x\n" , - value0, value1); +dev_dbg (vfe->camss->dev,"VFE: status0 = 0x%08x, status1 = 0x%08x\n" , + value0, value1);if (value0 &VFE_0_IRQ_STATUS_0_RESET_ACK ) vfe->isr_ops.reset_ack (vfe);drivers/media/platform/qcom/camss/camss-vfe-4-7.c +3
-3@@ -12,6 +12,7 @@#include <linux/io.h> #include <linux/iopoll.h> +#include "camss.h" #include "camss-vfe.h" #define VFE_0_HW_VERSION 0x000@@ -1069,8 +1070,8 @@ static irqreturn_t vfe_isr(int irq, void *dev) vfe->ops->isr_read (vfe, &value0, &value1); -trace_printk ("VFE: status0 = 0x%08x, status1 = 0x%08x\n" , - value0, value1); +dev_dbg (vfe->camss->dev,"VFE: status0 = 0x%08x, status1 = 0x%08x\n" , + value0, value1);if (value0 &VFE_0_IRQ_STATUS_0_RESET_ACK ) vfe->isr_ops.reset_ack (vfe); --2.27.0
PATCH v4 4/22 media: camss: Add CAMSS_845 camss version
In reply to Robert FossAdd enum representing the SDM845 SOC, which incorporates version 170 of the Titan architecture ISP.
--- drivers/media/platform/qcom/camss/camss.h | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/qcom/camss/camss.h +1 -0
@@ -66,6 +66,7 @@ enum camss_version { CAMSS_8x16, CAMSS_8x96,CAMSS_660 , + CAMSS_845, }; struct camss {
Signature · 1 line
2.27.0
PATCH v4 5/22 media: camss: Make ISPIF subdevice optional
In reply to Robert FossThis driver supports multiple architecture versions of the Qualcomm ISP. The CAMSS architecure which this driver is name after, and with the introduction of this series, the Titan architecture.
The ISPIF is an IP-block that is only present in the CAMSS generation of the architecture. In order to support the Titan generation, make the ISPIF an optional subdevice.
---
Changes since v1:
- Björn: Improved commit message
- Björn: Use local 'dev' ptr instead of 'camss->dev'
- Björn: Remove res/ispif NULL checks
- Björn: Remove ispif NULL checks before calling msm_ispif_unregister_entities()
- Andrey: Fixed incorrect allocation size
.../media/platform/qcom/camss/camss-ispif.c | 114 ++++++++++-------- .../media/platform/qcom/camss/camss-ispif.h | 3 +- drivers/media/platform/qcom/camss/camss.c | 111 +++++++++++------ drivers/media/platform/qcom/camss/camss.h | 2 +- 4 files changed, 142 insertions(+), 88 deletions(-)
drivers/media/platform/qcom/camss/camss-ispif.c +66 -48
@@ -161,6 +161,7 @@ static const u32 ispif_formats_8x96[] = {static irqreturn_t ispif_isr_8x96 (int irq,void *dev) {struct ispif_device *ispif = dev; +struct camss *camss = ispif->camss;u32 value0, value1, value2, value3, value4, value5; value0 =readl_relaxed (ispif->base +ISPIF_VFE_m_IRQ_STATUS_0 (0 ));
@@ -186,34 +187,34 @@ static irqreturn_t ispif_isr_8x96(int irq, void *dev)complete (&ispif->reset_complete[1 ]);if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix0 overflow\n" );if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi0 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix1 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi1 overflow\n" );if (unlikely (value2 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi2 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi2 overflow\n" );if (unlikely (value3 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 pix0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 pix0 overflow\n" );if (unlikely (value3 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 rdi0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 rdi0 overflow\n" );if (unlikely (value4 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 pix1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 pix1 overflow\n" );if (unlikely (value4 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 rdi1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 rdi1 overflow\n" );if (unlikely (value5 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 rdi2 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 rdi2 overflow\n" );return IRQ_HANDLED ; }
@@ -228,6 +229,7 @@ static irqreturn_t ispif_isr_8x96(int irq, void *dev)static irqreturn_t ispif_isr_8x16 (int irq,void *dev) {struct ispif_device *ispif = dev; +struct camss *camss = ispif->camss;u32 value0, value1, value2; value0 =readl_relaxed (ispif->base +ISPIF_VFE_m_IRQ_STATUS_0 (0 ));
@@ -244,30 +246,32 @@ static irqreturn_t ispif_isr_8x16(int irq, void *dev)complete (&ispif->reset_complete[0 ]);if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix0 overflow\n" );if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi0 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix1 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi1 overflow\n" );if (unlikely (value2 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi2 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi2 overflow\n" );return IRQ_HANDLED ; }static int ispif_vfe_reset (struct ispif_device *ispif,u8 vfe_id) { +struct camss *camss = ispif->camss; +unsigned long time;u32 val; -if (vfe_id > (to_camss (ispif)->vfe_num -1 )) { -dev_err (to_device (ispif), +if (vfe_id > (camss->vfe_num -1 )) { +dev_err (camss->dev,"Error: asked reset for invalid VFE%d\n" , vfe_id);return -ENOENT ; }
@@ -300,7 +304,7 @@ static int ispif_vfe_reset(struct ispif_device *ispif, u8 vfe_id) time =wait_for_completion_timeout (&ispif->reset_complete[vfe_id],msecs_to_jiffies (ISPIF_RESET_TIMEOUT_MS ));if (!time) { -dev_err (to_device (ispif), +dev_err (camss->dev,"ISPIF for VFE%d reset timeout\n" , vfe_id);return -EIO ; }
@@ -316,30 +320,31 @@ static int ispif_vfe_reset(struct ispif_device *ispif, u8 vfe_id)*/ static int ispif_reset (struct ispif_device *ispif,u8 vfe_id) { +struct camss *camss = ispif->camss;int ret; - ret =camss_pm_domain_on (to_camss (ispif),PM_DOMAIN_VFE0 ); + ret =camss_pm_domain_on (camss,PM_DOMAIN_VFE0 );if (ret <0 )return ret; - ret =camss_pm_domain_on (to_camss (ispif),PM_DOMAIN_VFE1 ); + ret =camss_pm_domain_on (camss,PM_DOMAIN_VFE1 );if (ret <0 )return ret; ret =camss_enable_clocks (ispif->nclocks_for_reset, ispif->clock_for_reset, -to_device (ispif)); + camss->dev);if (ret <0 )return ret; ret =ispif_vfe_reset (ispif, vfe_id);if (ret) -dev_dbg (to_device (ispif),"ISPIF Reset failed\n" ); +dev_dbg (camss->dev,"ISPIF Reset failed\n" );camss_disable_clocks (ispif->nclocks_for_reset, ispif->clock_for_reset); -camss_pm_domain_off (to_camss (ispif),PM_DOMAIN_VFE0 ); -camss_pm_domain_off (to_camss (ispif),PM_DOMAIN_VFE1 ); +camss_pm_domain_off (camss,PM_DOMAIN_VFE0 ); +camss_pm_domain_off (camss,PM_DOMAIN_VFE1 );return ret; }
@@ -355,7 +360,7 @@ static int ispif_set_power(struct v4l2_subdev *sd, int on) {struct ispif_line *line =v4l2_get_subdevdata (sd);struct ispif_device *ispif = line->ispif; -struct device *dev =to_device (ispif); +struct device *dev = ispif->camss->dev;int ret =0 ;mutex_lock (&ispif->power_lock);
@@ -505,7 +510,7 @@ static int ispif_validate_intf_status(struct ispif_device *ispif, }if ((val &0xf ) !=0xf ) { -dev_err (to_device (ispif),"%s: ispif is busy: 0x%x\n" , +dev_err (ispif->camss->dev,"%s: ispif is busy: 0x%x\n" , __func__, val); ret = -EBUSY ; }
@@ -552,7 +557,7 @@ static int ispif_wait_for_stop(struct ispif_device *ispif,ISPIF_TIMEOUT_SLEEP_US , ISPIF_TIMEOUT_ALL_US);if (ret <0 ) -dev_err (to_device (ispif),"%s: ispif stop timeout\n" , +dev_err (ispif->camss->dev,"%s: ispif stop timeout\n" , __func__);return ret;
@@ -800,6 +805,7 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int enable) {struct ispif_line *line =v4l2_get_subdevdata (sd);struct ispif_device *ispif = line->ispif; +struct camss *camss = ispif->camss;enum ispif_intf intf = line->interface;u8 csid = line->csid_id;u8 vfe = line->vfe_id;
@@ -825,8 +831,8 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int enable)ispif_select_csid (ispif, intf, csid, vfe,1 );ispif_select_cid (ispif, intf, cid, vfe,1 );ispif_config_irq (ispif, intf, vfe,1 ); -if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 )ispif_config_pack (ispif, line->fmt[MSM_ISPIF_PAD_SINK ].code, intf, cid, vfe,1 );
@@ -843,8 +849,8 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int enable)return ret;mutex_lock (&ispif->config_lock); -if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 )ispif_config_pack (ispif, line->fmt[MSM_ISPIF_PAD_SINK ].code, intf, cid, vfe,0 );
@@ -1088,26 +1094,29 @@ static int ispif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)* * Return 0 on success or a negative error code otherwise */ -int msm_ispif_subdev_init (struct ispif_device *ispif, +int msm_ispif_subdev_init (struct camss *camss,const struct resources_ispif *res) { -struct device *dev =to_device (ispif); +struct device *dev = camss->dev; +struct ispif_device *ispif = camss->ispif;struct platform_device *pdev =to_platform_device (dev);struct resource *r;int i;int ret; + ispif->camss = camss; +/* Number of ISPIF lines - same as number of CSID hardware modules */ -if (to_camss (ispif)->version == CAMSS_8x16) +if (camss->version == CAMSS_8x16) ispif->line_num =2 ; -else if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +else if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 ) ispif->line_num =4 ;else return -EINVAL ; - ispif->line =devm_kcalloc (dev, ispif->line_num,sizeof (*ispif->line), -GFP_KERNEL ); + ispif->line =devm_kcalloc (dev, ispif->line_num, +sizeof (*ispif->line),GFP_KERNEL );if (!ispif->line)return -ENOMEM ;
@@ -1115,12 +1124,12 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, ispif->line[i].ispif = ispif; ispif->line[i].id = i; -if (to_camss (ispif)->version == CAMSS_8x16) { +if (camss->version == CAMSS_8x16) { ispif->line[i].formats = ispif_formats_8x16; ispif->line[i].nformats =ARRAY_SIZE (ispif_formats_8x16); - }else if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) { + }else if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 ) { ispif->line[i].formats = ispif_formats_8x96; ispif->line[i].nformats =ARRAY_SIZE (ispif_formats_8x96);
@@ -1157,15 +1166,16 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, ispif->irq = r->start;snprintf (ispif->irq_name,sizeof (ispif->irq_name),"%s_%s" ,dev_name (dev),MSM_ISPIF_NAME ); -if (to_camss (ispif)->version == CAMSS_8x16) +if (camss->version == CAMSS_8x16) ret =devm_request_irq (dev, ispif->irq, ispif_isr_8x16,IRQF_TRIGGER_RISING , ispif->irq_name, ispif); -else if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +else if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 ) ret =devm_request_irq (dev, ispif->irq, ispif_isr_8x96,IRQF_TRIGGER_RISING , ispif->irq_name, ispif);else ret = -EINVAL ; +if (ret <0 ) {dev_err (dev,"request_irq failed: %d\n" , ret);return ret;
@@ -1331,10 +1341,13 @@ static const struct media_entity_operations ispif_media_ops = {int msm_ispif_register_entities (struct ispif_device *ispif,struct v4l2_device *v4l2_dev) { -struct device *dev =to_device (ispif); +struct camss *camss = ispif->camss;int ret;int i; +if (!ispif) +return 0 ; +for (i =0 ; i < ispif->line_num; i++) {struct v4l2_subdev *sd = &ispif->line[i].subdev;struct media_pad *pads = ispif->line[i].pads;
@@ -1348,7 +1361,7 @@ int msm_ispif_register_entities(struct ispif_device *ispif, ret =ispif_init_formats (sd,NULL );if (ret <0 ) { -dev_err (dev,"Failed to init format: %d\n" , ret); +dev_err (camss->dev,"Failed to init format: %d\n" , ret); goto error; }
@@ -1360,13 +1373,15 @@ int msm_ispif_register_entities(struct ispif_device *ispif, ret =media_entity_pads_init (&sd->entity,MSM_ISPIF_PADS_NUM , pads);if (ret <0 ) { -dev_err (dev,"Failed to init media entity: %d\n" , ret); +dev_err (camss->dev,"Failed to init media entity: %d\n" , + ret); goto error; } ret =v4l2_device_register_subdev (v4l2_dev, sd);if (ret <0 ) { -dev_err (dev,"Failed to register subdev: %d\n" , ret); +dev_err (camss->dev,"Failed to register subdev: %d\n" , + ret);media_entity_cleanup (&sd->entity); goto error; }
@@ -1393,6 +1408,9 @@ void msm_ispif_unregister_entities(struct ispif_device *ispif) {int i; +if (!ispif) +return ; +mutex_destroy (&ispif->power_lock);mutex_destroy (&ispif->config_lock);
drivers/media/platform/qcom/camss/camss-ispif.h +2 -1
@@ -63,11 +63,12 @@ struct ispif_device {struct mutex config_lock;unsigned int line_num;struct ispif_line *line; +struct camss *camss; };struct resources_ispif ; -int msm_ispif_subdev_init (struct ispif_device *ispif, +int msm_ispif_subdev_init (struct camss *camss,const struct resources_ispif *res); int msm_ispif_register_entities(struct ispif_device *ispif,
drivers/media/platform/qcom/camss/camss.c +73 -38
159 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss.h +1 -1
@@ -79,7 +79,7 @@ struct camss {struct csiphy_device *csiphy;int csid_num;struct csid_device *csid; -struct ispif_device ispif; +struct ispif_device *ispif;int vfe_num;struct vfe_device *vfe;atomic_t ref_count;
Signature · 1 line
2.27.0
Re: [PATCH v4 05/22] media: camss: Make ISPIF subdevice optional
Hi Robert,
Thank you for your patch!
Quoted 309 lines · Robert Foss
This driver supports multiple architecture versions of the Qualcomm ISP. The CAMSS architecure which this driver is name after, and with the introduction of this series, the Titan architecture.
The ISPIF is an IP-block that is only present in the CAMSS generation of the architecture. In order to support the Titan generation, make the ISPIF an optional subdevice.
Signed-off-by Robert Foss <[email protected]>---
Changes since v1:
- Björn: Improved commit message
- Björn: Use local 'dev' ptr instead of 'camss->dev'
- Björn: Remove res/ispif NULL checks
- Björn: Remove ispif NULL checks before callingmsm_ispif_unregister_entities()
- Andrey: Fixed incorrect allocation size.../media/platform/qcom/camss/camss-ispif.c | 114 ++++++++++-------- .../media/platform/qcom/camss/camss-ispif.h | 3 +- drivers/media/platform/qcom/camss/camss.c | 111 +++++++++++------ drivers/media/platform/qcom/camss/camss.h | 2 +- 4 files changed, 142 insertions(+), 88 deletions(-)drivers/media/platform/qcom/camss/camss-ispif.c +54
-44@@ -161,6 +161,7 @@ static const u32 ispif_formats_8x96[] = {static irqreturn_t ispif_isr_8x96 (int irq,void *dev) {struct ispif_device *ispif = dev; +struct camss *camss = ispif->camss;u32 value0, value1, value2, value3, value4, value5; value0 =readl_relaxed (ispif->base +ISPIF_VFE_m_IRQ_STATUS_0 (0 ));@@ -186,34 +187,34 @@ static irqreturn_t ispif_isr_8x96(int irq, void *dev)complete (&ispif->reset_complete[1 ]);if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix0 overflow\n" );if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi0 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix1 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi1 overflow\n" );if (unlikely (value2 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi2 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi2 overflow\n" );if (unlikely (value3 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 pix0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 pix0 overflow\n" );if (unlikely (value3 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 rdi0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 rdi0 overflow\n" );if (unlikely (value4 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 pix1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 pix1 overflow\n" );if (unlikely (value4 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 rdi1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 rdi1 overflow\n" );if (unlikely (value5 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 rdi2 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 rdi2 overflow\n" );return IRQ_HANDLED ; }@@ -228,6 +229,7 @@ static irqreturn_t ispif_isr_8x96(int irq, void *dev)static irqreturn_t ispif_isr_8x16 (int irq,void *dev) {struct ispif_device *ispif = dev; +struct camss *camss = ispif->camss;u32 value0, value1, value2; value0 =readl_relaxed (ispif->base +ISPIF_VFE_m_IRQ_STATUS_0 (0 ));@@ -244,30 +246,32 @@ static irqreturn_t ispif_isr_8x16(int irq, void *dev)complete (&ispif->reset_complete[0 ]);if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix0 overflow\n" );if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi0 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix1 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi1 overflow\n" );if (unlikely (value2 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi2 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi2 overflow\n" );return IRQ_HANDLED ; }static int ispif_vfe_reset (struct ispif_device *ispif,u8 vfe_id) { +struct camss *camss = ispif->camss; +unsigned long time;u32 val; -if (vfe_id > (to_camss (ispif)->vfe_num -1 )) { -dev_err (to_device (ispif), +if (vfe_id > (camss->vfe_num -1 )) { +dev_err (camss->dev,"Error: asked reset for invalid VFE%d\n" , vfe_id);return -ENOENT ; }@@ -300,7 +304,7 @@ static int ispif_vfe_reset(struct ispif_device *ispif, u8 vfe_id) time =wait_for_completion_timeout (&ispif->reset_complete[vfe_id],msecs_to_jiffies (ISPIF_RESET_TIMEOUT_MS ));if (!time) { -dev_err (to_device (ispif), +dev_err (camss->dev,"ISPIF for VFE%d reset timeout\n" , vfe_id);return -EIO ; }@@ -316,30 +320,31 @@ static int ispif_vfe_reset(struct ispif_device *ispif, u8 vfe_id)*/ static int ispif_reset (struct ispif_device *ispif,u8 vfe_id) { +struct camss *camss = ispif->camss;int ret; - ret =camss_pm_domain_on (to_camss (ispif),PM_DOMAIN_VFE0 ); + ret =camss_pm_domain_on (camss,PM_DOMAIN_VFE0 );if (ret <0 )return ret; - ret =camss_pm_domain_on (to_camss (ispif),PM_DOMAIN_VFE1 ); + ret =camss_pm_domain_on (camss,PM_DOMAIN_VFE1 );if (ret <0 )return ret; ret =camss_enable_clocks (ispif->nclocks_for_reset, ispif->clock_for_reset, -to_device (ispif)); + camss->dev);if (ret <0 )return ret; ret =ispif_vfe_reset (ispif, vfe_id);if (ret) -dev_dbg (to_device (ispif),"ISPIF Reset failed\n" ); +dev_dbg (camss->dev,"ISPIF Reset failed\n" );camss_disable_clocks (ispif->nclocks_for_reset, ispif->clock_for_reset); -camss_pm_domain_off (to_camss (ispif),PM_DOMAIN_VFE0 ); -camss_pm_domain_off (to_camss (ispif),PM_DOMAIN_VFE1 ); +camss_pm_domain_off (camss,PM_DOMAIN_VFE0 ); +camss_pm_domain_off (camss,PM_DOMAIN_VFE1 );return ret; }@@ -355,7 +360,7 @@ static int ispif_set_power(struct v4l2_subdev *sd, int on) {struct ispif_line *line =v4l2_get_subdevdata (sd);struct ispif_device *ispif = line->ispif; -struct device *dev =to_device (ispif); +struct device *dev = ispif->camss->dev;int ret =0 ;mutex_lock (&ispif->power_lock);@@ -505,7 +510,7 @@ static int ispif_validate_intf_status(struct ispif_device *ispif, }if ((val &0xf ) !=0xf ) { -dev_err (to_device (ispif),"%s: ispif is busy: 0x%x\n" , +dev_err (ispif->camss->dev,"%s: ispif is busy: 0x%x\n" , __func__, val); ret = -EBUSY ; }@@ -552,7 +557,7 @@ static int ispif_wait_for_stop(struct ispif_device *ispif,ISPIF_TIMEOUT_SLEEP_US , ISPIF_TIMEOUT_ALL_US);if (ret <0 ) -dev_err (to_device (ispif),"%s: ispif stop timeout\n" , +dev_err (ispif->camss->dev,"%s: ispif stop timeout\n" , __func__);return ret;@@ -800,6 +805,7 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int enable) {struct ispif_line *line =v4l2_get_subdevdata (sd);struct ispif_device *ispif = line->ispif; +struct camss *camss = ispif->camss;enum ispif_intf intf = line->interface;u8 csid = line->csid_id;u8 vfe = line->vfe_id;@@ -825,8 +831,8 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int enable)ispif_select_csid (ispif, intf, csid, vfe,1 );ispif_select_cid (ispif, intf, cid, vfe,1 );ispif_config_irq (ispif, intf, vfe,1 ); -if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 )ispif_config_pack (ispif, line->fmt[MSM_ISPIF_PAD_SINK ].code, intf, cid, vfe,1 );@@ -843,8 +849,8 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int enable)return ret;mutex_lock (&ispif->config_lock); -if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 )ispif_config_pack (ispif, line->fmt[MSM_ISPIF_PAD_SINK ].code, intf, cid, vfe,0 );@@ -1088,26 +1094,29 @@ static int ispif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)* * Return 0 on success or a negative error code otherwise */ -int msm_ispif_subdev_init (struct ispif_device *ispif, +int msm_ispif_subdev_init (struct camss *camss,const struct resources_ispif *res) { -struct device *dev =to_device (ispif); +struct device *dev = camss->dev; +struct ispif_device *ispif = camss->ispif;struct platform_device *pdev =to_platform_device (dev);struct resource *r;int i;int ret; + ispif->camss = camss; +/* Number of ISPIF lines - same as number of CSID hardware modules */ -if (to_camss (ispif)->version == CAMSS_8x16) +if (camss->version == CAMSS_8x16) ispif->line_num =2 ; -else if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +else if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 ) ispif->line_num =4 ;else return -EINVAL ; - ispif->line =devm_kcalloc (dev, ispif->line_num,sizeof (*ispif->line), -GFP_KERNEL ); + ispif->line =devm_kcalloc (dev, ispif->line_num, +sizeof (*ispif->line),GFP_KERNEL );if (!ispif->line)return -ENOMEM ;@@ -1115,12 +1124,12 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, ispif->line[i].ispif = ispif; ispif->line[i].id = i; -if (to_camss (ispif)->version == CAMSS_8x16) { +if (camss->version == CAMSS_8x16) { ispif->line[i].formats = ispif_formats_8x16; ispif->line[i].nformats =ARRAY_SIZE (ispif_formats_8x16); - }else if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) { + }else if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 ) { ispif->line[i].formats = ispif_formats_8x96; ispif->line[i].nformats =ARRAY_SIZE (ispif_formats_8x96);@@ -1157,15 +1166,16 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, ispif->irq = r->start;snprintf (ispif->irq_name,sizeof (ispif->irq_name),"%s_%s" ,dev_name (dev),MSM_ISPIF_NAME ); -if (to_camss (ispif)->version == CAMSS_8x16) +if (camss->version == CAMSS_8x16) ret =devm_request_irq (dev, ispif->irq, ispif_isr_8x16,IRQF_TRIGGER_RISING , ispif->irq_name, ispif); -else if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +else if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 ) ret =devm_request_irq (dev, ispif->irq, ispif_isr_8x96,IRQF_TRIGGER_RISING , ispif->irq_name, ispif);else ret = -EINVAL ; +if (ret <0 ) {dev_err (dev,"request_irq failed: %d\n" , ret);return ret;
drivers/media/platform/qcom/camss/camss-ispif.c static const struct media_entity_operations ispif_media_ops = { · line 1344
Quoted 5 lines
drivers/media/platform/qcom/camss/camss-ispif.c +1
-1@@ -1331,10 +1341,13 @@ static const struct media_entity_operations ispif_media_ops = {int msm_ispif_register_entities (struct ispif_device *ispif,struct v4l2_device *v4l2_dev) { -struct device *dev =to_device (ispif); +struct camss *camss = ispif->camss;
- here ispif is used before the if (!ispif) check below...
drivers/media/platform/qcom/camss/camss-ispif.c static const struct media_entity_operations ispif_media_ops = { · line 1346
Quoted 2 lines
drivers/media/platform/qcom/camss/camss-ispif.c +0
-0int ret;int i;
... and here is the check:
drivers/media/platform/qcom/camss/camss-ispif.c static const struct media_entity_operations ispif_media_ops = { · line 1349
Quoted 2 lines
drivers/media/platform/qcom/camss/camss-ispif.c +2
-0+if (!ispif) +return 0 ;
Thanks,
Andrey
Quoted 242 lines
drivers/media/platform/qcom/camss/camss-ispif.c +9
-3+for (i =0 ; i < ispif->line_num; i++) {struct v4l2_subdev *sd = &ispif->line[i].subdev;struct media_pad *pads = ispif->line[i].pads;@@ -1348,7 +1361,7 @@ int msm_ispif_register_entities(struct ispif_device *ispif, ret =ispif_init_formats (sd,NULL );if (ret <0 ) { -dev_err (dev,"Failed to init format: %d\n" , ret); +dev_err (camss->dev,"Failed to init format: %d\n" , ret); goto error; }@@ -1360,13 +1373,15 @@ int msm_ispif_register_entities(struct ispif_device *ispif, ret =media_entity_pads_init (&sd->entity,MSM_ISPIF_PADS_NUM , pads);if (ret <0 ) { -dev_err (dev,"Failed to init media entity: %d\n" , ret); +dev_err (camss->dev,"Failed to init media entity: %d\n" , + ret); goto error; } ret =v4l2_device_register_subdev (v4l2_dev, sd);if (ret <0 ) { -dev_err (dev,"Failed to register subdev: %d\n" , ret); +dev_err (camss->dev,"Failed to register subdev: %d\n" , + ret);media_entity_cleanup (&sd->entity); goto error; }@@ -1393,6 +1408,9 @@ void msm_ispif_unregister_entities(struct ispif_device *ispif) {int i; +if (!ispif) +return ; +mutex_destroy (&ispif->power_lock);mutex_destroy (&ispif->config_lock);drivers/media/platform/qcom/camss/camss-ispif.h +2
-1@@ -63,11 +63,12 @@ struct ispif_device {struct mutex config_lock;unsigned int line_num;struct ispif_line *line; +struct camss *camss; };struct resources_ispif ; -int msm_ispif_subdev_init (struct ispif_device *ispif, +int msm_ispif_subdev_init (struct camss *camss,const struct resources_ispif *res); int msm_ispif_register_entities(struct ispif_device *ispif,drivers/media/platform/qcom/camss/camss.c +73
-38@@ -748,11 +748,13 @@ static int camss_init_subdevices(struct camss *camss) } } - ret =msm_ispif_subdev_init (&camss->ispif, ispif_res); -if (ret <0 ) { -dev_err (camss->dev,"Failed to init ispif sub-device: %d\n" , +if (camss->ispif) { + ret =msm_ispif_subdev_init (camss, ispif_res); +if (ret <0 ) { +dev_err (camss->dev,"Failed to init ispif sub-device: %d\n" , ret); -return ret; +return ret; + } }for (i =0 ; i < camss->vfe_num; i++) {@@ -801,11 +803,14 @@ static int camss_register_entities(struct camss *camss) } } - ret =msm_ispif_register_entities (&camss->ispif, &camss->v4l2_dev); -if (ret <0 ) { -dev_err (camss->dev,"Failed to register ispif entities: %d\n" , +if (camss->ispif) { + ret =msm_ispif_register_entities (camss->ispif, + &camss->v4l2_dev); +if (ret <0 ) { +dev_err (camss->dev,"Failed to register ispif entities: %d\n" , ret); - goto err_reg_ispif; + goto err_reg_ispif; + } }for (i =0 ; i < camss->vfe_num; i++) {@@ -838,43 +843,64 @@ static int camss_register_entities(struct camss *camss) } } -for (i =0 ; i < camss->csid_num; i++) { -for (j =0 ; j < camss->ispif.line_num; j++) { - ret =media_create_pad_link ( - &camss->csid[i].subdev.entity, -MSM_CSID_PAD_SRC , - &camss->ispif.line[j].subdev.entity, -MSM_ISPIF_PAD_SINK , -0 ); -if (ret <0 ) { -dev_err (camss->dev, -"Failed to link %s->%s entities: %d\n" , - camss->csid[i].subdev.entity.name, - camss->ispif.line[j].subdev.entity.name, - ret); - goto err_link; - } - } - } - -for (i =0 ; i < camss->ispif.line_num; i++) -for (k =0 ; k < camss->vfe_num; k++) -for (j =0 ; j <ARRAY_SIZE (camss->vfe[k].line); j++) { +if (camss->ispif) { +for (i =0 ; i < camss->csid_num; i++) { +for (j =0 ; j < camss->ispif->line_num; j++) { ret =media_create_pad_link ( - &camss->ispif.line[i].subdev.entity, -MSM_ISPIF_PAD_SRC , - &camss->vfe[k].line[j].subdev.entity, -MSM_VFE_PAD_SINK , + &camss->csid[i].subdev.entity, +MSM_CSID_PAD_SRC , + &camss->ispif->line[j].subdev.entity, +MSM_ISPIF_PAD_SINK ,0 );if (ret <0 ) {dev_err (camss->dev,"Failed to link %s->%s entities: %d\n" , - camss->ispif.line[i].subdev.entity.name, - camss->vfe[k].line[j].subdev.entity.name, + camss->csid[i].subdev.entity.name, + camss->ispif->line[j].subdev.entity.name, ret); goto err_link; } } + } + +for (i =0 ; i < camss->ispif->line_num; i++) +for (k =0 ; k < camss->vfe_num; k++) +for (j =0 ; j <ARRAY_SIZE (camss->vfe[k].line); j++) { + ret =media_create_pad_link ( + &camss->ispif->line[i].subdev.entity, +MSM_ISPIF_PAD_SRC , + &camss->vfe[k].line[j].subdev.entity, +MSM_VFE_PAD_SINK , +0 ); +if (ret <0 ) { +dev_err (camss->dev, +"Failed to link %s->%s entities: %d\n" , + camss->ispif->line[i].subdev.entity.name, + camss->vfe[k].line[j].subdev.entity.name, + ret); + goto err_link; + } + } + }else { +for (i =0 ; i < camss->csid_num; i++) +for (k =0 ; k < camss->vfe_num; k++) +for (j =0 ; j <ARRAY_SIZE (camss->vfe[k].line); j++) { + ret =media_create_pad_link ( + &camss->csid[i].subdev.entity, +MSM_CSID_PAD_SRC , + &camss->vfe[k].line[j].subdev.entity, +MSM_VFE_PAD_SINK , +0 ); +if (ret <0 ) { +dev_err (camss->dev, +"Failed to link %s->%s entities: %d\n" , + camss->csid[i].subdev.entity.name, + camss->vfe[k].line[j].subdev.entity.name, + ret); + goto err_link; + } + } + }return 0 ;@@ -884,8 +910,8 @@ static int camss_register_entities(struct camss *camss)for (i--; i >=0 ; i--)msm_vfe_unregister_entities (&camss->vfe[i]); -msm_ispif_unregister_entities (&camss->ispif); err_reg_ispif: +msm_ispif_unregister_entities (camss->ispif); i = camss->csid_num; err_reg_csid:@@ -916,7 +942,7 @@ static void camss_unregister_entities(struct camss *camss)for (i =0 ; i < camss->csid_num; i++)msm_csid_unregister_entity (&camss->csid[i]); -msm_ispif_unregister_entities (&camss->ispif); +msm_ispif_unregister_entities (camss->ispif);for (i =0 ; i < camss->vfe_num; i++)msm_vfe_unregister_entities (&camss->vfe[i]);@@ -1047,6 +1073,15 @@ static int camss_probe(struct platform_device *pdev) goto err_free; } +if (camss->version == CAMSS_8x16 || + camss->version == CAMSS_8x96) { + camss->ispif =devm_kcalloc (dev,1 ,sizeof (*camss->ispif),GFP_KERNEL ); +if (!camss->ispif) { + ret = -ENOMEM ; + goto err_free; + } + } + camss->vfe =devm_kcalloc (dev, camss->vfe_num,sizeof (*camss->vfe),GFP_KERNEL );if (!camss->vfe) {drivers/media/platform/qcom/camss/camss.h +1
-1@@ -79,7 +79,7 @@ struct camss {struct csiphy_device *csiphy;int csid_num;struct csid_device *csid; -struct ispif_device ispif; +struct ispif_device *ispif;int vfe_num;struct vfe_device *vfe;atomic_t ref_count;
Re: [PATCH v4 05/22] media: camss: Make ISPIF subdevice optional
Hey Andrey,
Thanks for starting this review!
Quoted 314 lines · Andrey Konovalov
Hi Robert,
Thank you for your patch!
Quoted 308 lines · Robert Foss
This driver supports multiple architecture versions of the Qualcomm ISP. The CAMSS architecure which this driver is name after, and with the introduction of this series, the Titan architecture.
The ISPIF is an IP-block that is only present in the CAMSS generation of the architecture. In order to support the Titan generation, make the ISPIF an optional subdevice.
Signed-off-by Robert Foss <[email protected]>---
Changes since v1:
- Björn: Improved commit message
- Björn: Use local 'dev' ptr instead of 'camss->dev'
- Björn: Remove res/ispif NULL checks
- Björn: Remove ispif NULL checks before callingmsm_ispif_unregister_entities()
- Andrey: Fixed incorrect allocation size.../media/platform/qcom/camss/camss-ispif.c | 114 ++++++++++-------- .../media/platform/qcom/camss/camss-ispif.h | 3 +- drivers/media/platform/qcom/camss/camss.c | 111 +++++++++++------ drivers/media/platform/qcom/camss/camss.h | 2 +- 4 files changed, 142 insertions(+), 88 deletions(-)drivers/media/platform/qcom/camss/camss-ispif.c +54
-44@@ -161,6 +161,7 @@ static const u32 ispif_formats_8x96[] = {static irqreturn_t ispif_isr_8x96 (int irq,void *dev) {struct ispif_device *ispif = dev; +struct camss *camss = ispif->camss;u32 value0, value1, value2, value3, value4, value5; value0 =readl_relaxed (ispif->base +ISPIF_VFE_m_IRQ_STATUS_0 (0 ));@@ -186,34 +187,34 @@ static irqreturn_t ispif_isr_8x96(int irq, void *dev)complete (&ispif->reset_complete[1 ]);if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix0 overflow\n" );if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi0 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix1 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi1 overflow\n" );if (unlikely (value2 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi2 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi2 overflow\n" );if (unlikely (value3 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 pix0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 pix0 overflow\n" );if (unlikely (value3 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 rdi0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 rdi0 overflow\n" );if (unlikely (value4 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 pix1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 pix1 overflow\n" );if (unlikely (value4 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 rdi1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 rdi1 overflow\n" );if (unlikely (value5 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE1 rdi2 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE1 rdi2 overflow\n" );return IRQ_HANDLED ; }@@ -228,6 +229,7 @@ static irqreturn_t ispif_isr_8x96(int irq, void *dev)static irqreturn_t ispif_isr_8x16 (int irq,void *dev) {struct ispif_device *ispif = dev; +struct camss *camss = ispif->camss;u32 value0, value1, value2; value0 =readl_relaxed (ispif->base +ISPIF_VFE_m_IRQ_STATUS_0 (0 ));@@ -244,30 +246,32 @@ static irqreturn_t ispif_isr_8x16(int irq, void *dev)complete (&ispif->reset_complete[0 ]);if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_PIX0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix0 overflow\n" );if (unlikely (value0 & ISPIF_VFE_m_IRQ_STATUS_0_RDI0_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi0 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi0 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_PIX1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 pix1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 pix1 overflow\n" );if (unlikely (value1 & ISPIF_VFE_m_IRQ_STATUS_1_RDI1_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi1 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi1 overflow\n" );if (unlikely (value2 & ISPIF_VFE_m_IRQ_STATUS_2_RDI2_OVERFLOW)) -dev_err_ratelimited (to_device (ispif),"VFE0 rdi2 overflow\n" ); +dev_err_ratelimited (camss->dev,"VFE0 rdi2 overflow\n" );return IRQ_HANDLED ; }static int ispif_vfe_reset (struct ispif_device *ispif,u8 vfe_id) { +struct camss *camss = ispif->camss; +unsigned long time;u32 val; -if (vfe_id > (to_camss (ispif)->vfe_num -1 )) { -dev_err (to_device (ispif), +if (vfe_id > (camss->vfe_num -1 )) { +dev_err (camss->dev,"Error: asked reset for invalid VFE%d\n" , vfe_id);return -ENOENT ; }@@ -300,7 +304,7 @@ static int ispif_vfe_reset(struct ispif_device *ispif, u8 vfe_id) time =wait_for_completion_timeout (&ispif->reset_complete[vfe_id],msecs_to_jiffies (ISPIF_RESET_TIMEOUT_MS ));if (!time) { -dev_err (to_device (ispif), +dev_err (camss->dev,"ISPIF for VFE%d reset timeout\n" , vfe_id);return -EIO ; }@@ -316,30 +320,31 @@ static int ispif_vfe_reset(struct ispif_device *ispif, u8 vfe_id)*/ static int ispif_reset (struct ispif_device *ispif,u8 vfe_id) { +struct camss *camss = ispif->camss;int ret; - ret =camss_pm_domain_on (to_camss (ispif),PM_DOMAIN_VFE0 ); + ret =camss_pm_domain_on (camss,PM_DOMAIN_VFE0 );if (ret <0 )return ret; - ret =camss_pm_domain_on (to_camss (ispif),PM_DOMAIN_VFE1 ); + ret =camss_pm_domain_on (camss,PM_DOMAIN_VFE1 );if (ret <0 )return ret; ret =camss_enable_clocks (ispif->nclocks_for_reset, ispif->clock_for_reset, -to_device (ispif)); + camss->dev);if (ret <0 )return ret; ret =ispif_vfe_reset (ispif, vfe_id);if (ret) -dev_dbg (to_device (ispif),"ISPIF Reset failed\n" ); +dev_dbg (camss->dev,"ISPIF Reset failed\n" );camss_disable_clocks (ispif->nclocks_for_reset, ispif->clock_for_reset); -camss_pm_domain_off (to_camss (ispif),PM_DOMAIN_VFE0 ); -camss_pm_domain_off (to_camss (ispif),PM_DOMAIN_VFE1 ); +camss_pm_domain_off (camss,PM_DOMAIN_VFE0 ); +camss_pm_domain_off (camss,PM_DOMAIN_VFE1 );return ret; }@@ -355,7 +360,7 @@ static int ispif_set_power(struct v4l2_subdev *sd, int on) {struct ispif_line *line =v4l2_get_subdevdata (sd);struct ispif_device *ispif = line->ispif; -struct device *dev =to_device (ispif); +struct device *dev = ispif->camss->dev;int ret =0 ;mutex_lock (&ispif->power_lock);@@ -505,7 +510,7 @@ static int ispif_validate_intf_status(struct ispif_device *ispif, }if ((val &0xf ) !=0xf ) { -dev_err (to_device (ispif),"%s: ispif is busy: 0x%x\n" , +dev_err (ispif->camss->dev,"%s: ispif is busy: 0x%x\n" , __func__, val); ret = -EBUSY ; }@@ -552,7 +557,7 @@ static int ispif_wait_for_stop(struct ispif_device *ispif,ISPIF_TIMEOUT_SLEEP_US , ISPIF_TIMEOUT_ALL_US);if (ret <0 ) -dev_err (to_device (ispif),"%s: ispif stop timeout\n" , +dev_err (ispif->camss->dev,"%s: ispif stop timeout\n" , __func__);return ret;@@ -800,6 +805,7 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int enable) {struct ispif_line *line =v4l2_get_subdevdata (sd);struct ispif_device *ispif = line->ispif; +struct camss *camss = ispif->camss;enum ispif_intf intf = line->interface;u8 csid = line->csid_id;u8 vfe = line->vfe_id;@@ -825,8 +831,8 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int enable)ispif_select_csid (ispif, intf, csid, vfe,1 );ispif_select_cid (ispif, intf, cid, vfe,1 );ispif_config_irq (ispif, intf, vfe,1 ); -if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 )ispif_config_pack (ispif, line->fmt[MSM_ISPIF_PAD_SINK ].code, intf, cid, vfe,1 );@@ -843,8 +849,8 @@ static int ispif_set_stream(struct v4l2_subdev *sd, int enable)return ret;mutex_lock (&ispif->config_lock); -if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 )ispif_config_pack (ispif, line->fmt[MSM_ISPIF_PAD_SINK ].code, intf, cid, vfe,0 );@@ -1088,26 +1094,29 @@ static int ispif_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)* * Return 0 on success or a negative error code otherwise */ -int msm_ispif_subdev_init (struct ispif_device *ispif, +int msm_ispif_subdev_init (struct camss *camss,const struct resources_ispif *res) { -struct device *dev =to_device (ispif); +struct device *dev = camss->dev; +struct ispif_device *ispif = camss->ispif;struct platform_device *pdev =to_platform_device (dev);struct resource *r;int i;int ret; + ispif->camss = camss; +/* Number of ISPIF lines - same as number of CSID hardware modules */ -if (to_camss (ispif)->version == CAMSS_8x16) +if (camss->version == CAMSS_8x16) ispif->line_num =2 ; -else if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +else if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 ) ispif->line_num =4 ;else return -EINVAL ; - ispif->line =devm_kcalloc (dev, ispif->line_num,sizeof (*ispif->line), -GFP_KERNEL ); + ispif->line =devm_kcalloc (dev, ispif->line_num, +sizeof (*ispif->line),GFP_KERNEL );if (!ispif->line)return -ENOMEM ;@@ -1115,12 +1124,12 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, ispif->line[i].ispif = ispif; ispif->line[i].id = i; -if (to_camss (ispif)->version == CAMSS_8x16) { +if (camss->version == CAMSS_8x16) { ispif->line[i].formats = ispif_formats_8x16; ispif->line[i].nformats =ARRAY_SIZE (ispif_formats_8x16); - }else if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) { + }else if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 ) { ispif->line[i].formats = ispif_formats_8x96; ispif->line[i].nformats =ARRAY_SIZE (ispif_formats_8x96);@@ -1157,15 +1166,16 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, ispif->irq = r->start;snprintf (ispif->irq_name,sizeof (ispif->irq_name),"%s_%s" ,dev_name (dev),MSM_ISPIF_NAME ); -if (to_camss (ispif)->version == CAMSS_8x16) +if (camss->version == CAMSS_8x16) ret =devm_request_irq (dev, ispif->irq, ispif_isr_8x16,IRQF_TRIGGER_RISING , ispif->irq_name, ispif); -else if (to_camss (ispif)->version == CAMSS_8x96 || -to_camss (ispif)->version ==CAMSS_660 ) +else if (camss->version == CAMSS_8x96 || + camss->version ==CAMSS_660 ) ret =devm_request_irq (dev, ispif->irq, ispif_isr_8x96,IRQF_TRIGGER_RISING , ispif->irq_name, ispif);else ret = -EINVAL ; +if (ret <0 ) {dev_err (dev,"request_irq failed: %d\n" , ret);return ret;
Quoted 8 lines
drivers/media/platform/qcom/camss/camss-ispif.c static const struct media_entity_operations ispif_media_ops = { · line 1344
Quoted 6 lines
drivers/media/platform/qcom/camss/camss-ispif.c +1
-1@@ -1331,10 +1341,13 @@ static const struct media_entity_operations ispif_media_ops = {int msm_ispif_register_entities (struct ispif_device *ispif,struct v4l2_device *v4l2_dev) { -struct device *dev =to_device (ispif); +struct camss *camss = ispif->camss;- here ispif is used before the if (!ispif) check below...
You are completely right, but due to another mistake this code actually works ok. msm_ispif_register_entities() is only called is camss->ispif is set, so we're not going to do NULL derefs.
Quoted 5 lines
drivers/media/platform/qcom/camss/camss-ispif.c static const struct media_entity_operations ispif_media_ops = { · line 1346
Quoted 3 lines
drivers/media/platform/qcom/camss/camss-ispif.c +0
-0int ret;int i;... and here is the check:
Let's fix this check and remove the check in camss.c
Quoted 249 lines
drivers/media/platform/qcom/camss/camss-ispif.c static const struct media_entity_operations ispif_media_ops = { · line 1349
Quoted 3 lines
drivers/media/platform/qcom/camss/camss-ispif.c +2
-0+if (!ispif) +return 0 ;Thanks,
AndreyQuoted 242 lines
drivers/media/platform/qcom/camss/camss-ispif.c +9
-3+for (i =0 ; i < ispif->line_num; i++) {struct v4l2_subdev *sd = &ispif->line[i].subdev;struct media_pad *pads = ispif->line[i].pads;@@ -1348,7 +1361,7 @@ int msm_ispif_register_entities(struct ispif_device *ispif, ret =ispif_init_formats (sd,NULL );if (ret <0 ) { -dev_err (dev,"Failed to init format: %d\n" , ret); +dev_err (camss->dev,"Failed to init format: %d\n" , ret); goto error; }@@ -1360,13 +1373,15 @@ int msm_ispif_register_entities(struct ispif_device *ispif, ret =media_entity_pads_init (&sd->entity,MSM_ISPIF_PADS_NUM , pads);if (ret <0 ) { -dev_err (dev,"Failed to init media entity: %d\n" , ret); +dev_err (camss->dev,"Failed to init media entity: %d\n" , + ret); goto error; } ret =v4l2_device_register_subdev (v4l2_dev, sd);if (ret <0 ) { -dev_err (dev,"Failed to register subdev: %d\n" , ret); +dev_err (camss->dev,"Failed to register subdev: %d\n" , + ret);media_entity_cleanup (&sd->entity); goto error; }@@ -1393,6 +1408,9 @@ void msm_ispif_unregister_entities(struct ispif_device *ispif) {int i; +if (!ispif) +return ; +mutex_destroy (&ispif->power_lock);mutex_destroy (&ispif->config_lock);drivers/media/platform/qcom/camss/camss-ispif.h +2
-1@@ -63,11 +63,12 @@ struct ispif_device {struct mutex config_lock;unsigned int line_num;struct ispif_line *line; +struct camss *camss; };struct resources_ispif ; -int msm_ispif_subdev_init (struct ispif_device *ispif, +int msm_ispif_subdev_init (struct camss *camss,const struct resources_ispif *res); int msm_ispif_register_entities(struct ispif_device *ispif,drivers/media/platform/qcom/camss/camss.c +73
-38@@ -748,11 +748,13 @@ static int camss_init_subdevices(struct camss *camss) } } - ret =msm_ispif_subdev_init (&camss->ispif, ispif_res); -if (ret <0 ) { -dev_err (camss->dev,"Failed to init ispif sub-device: %d\n" , +if (camss->ispif) { + ret =msm_ispif_subdev_init (camss, ispif_res); +if (ret <0 ) { +dev_err (camss->dev,"Failed to init ispif sub-device: %d\n" , ret); -return ret; +return ret; + } }for (i =0 ; i < camss->vfe_num; i++) {@@ -801,11 +803,14 @@ static int camss_register_entities(struct camss *camss) } } - ret =msm_ispif_register_entities (&camss->ispif, &camss->v4l2_dev); -if (ret <0 ) { -dev_err (camss->dev,"Failed to register ispif entities: %d\n" , +if (camss->ispif) { + ret =msm_ispif_register_entities (camss->ispif, + &camss->v4l2_dev); +if (ret <0 ) { +dev_err (camss->dev,"Failed to register ispif entities: %d\n" , ret); - goto err_reg_ispif; + goto err_reg_ispif; + } }for (i =0 ; i < camss->vfe_num; i++) {@@ -838,43 +843,64 @@ static int camss_register_entities(struct camss *camss) } } -for (i =0 ; i < camss->csid_num; i++) { -for (j =0 ; j < camss->ispif.line_num; j++) { - ret =media_create_pad_link ( - &camss->csid[i].subdev.entity, -MSM_CSID_PAD_SRC , - &camss->ispif.line[j].subdev.entity, -MSM_ISPIF_PAD_SINK , -0 ); -if (ret <0 ) { -dev_err (camss->dev, -"Failed to link %s->%s entities: %d\n" , - camss->csid[i].subdev.entity.name, - camss->ispif.line[j].subdev.entity.name, - ret); - goto err_link; - } - } - } - -for (i =0 ; i < camss->ispif.line_num; i++) -for (k =0 ; k < camss->vfe_num; k++) -for (j =0 ; j <ARRAY_SIZE (camss->vfe[k].line); j++) { +if (camss->ispif) { +for (i =0 ; i < camss->csid_num; i++) { +for (j =0 ; j < camss->ispif->line_num; j++) { ret =media_create_pad_link ( - &camss->ispif.line[i].subdev.entity, -MSM_ISPIF_PAD_SRC , - &camss->vfe[k].line[j].subdev.entity, -MSM_VFE_PAD_SINK , + &camss->csid[i].subdev.entity, +MSM_CSID_PAD_SRC , + &camss->ispif->line[j].subdev.entity, +MSM_ISPIF_PAD_SINK ,0 );if (ret <0 ) {dev_err (camss->dev,"Failed to link %s->%s entities: %d\n" , - camss->ispif.line[i].subdev.entity.name, - camss->vfe[k].line[j].subdev.entity.name, + camss->csid[i].subdev.entity.name, + camss->ispif->line[j].subdev.entity.name, ret); goto err_link; } } + } + +for (i =0 ; i < camss->ispif->line_num; i++) +for (k =0 ; k < camss->vfe_num; k++) +for (j =0 ; j <ARRAY_SIZE (camss->vfe[k].line); j++) { + ret =media_create_pad_link ( + &camss->ispif->line[i].subdev.entity, +MSM_ISPIF_PAD_SRC , + &camss->vfe[k].line[j].subdev.entity, +MSM_VFE_PAD_SINK , +0 ); +if (ret <0 ) { +dev_err (camss->dev, +"Failed to link %s->%s entities: %d\n" , + camss->ispif->line[i].subdev.entity.name, + camss->vfe[k].line[j].subdev.entity.name, + ret); + goto err_link; + } + } + }else { +for (i =0 ; i < camss->csid_num; i++) +for (k =0 ; k < camss->vfe_num; k++) +for (j =0 ; j <ARRAY_SIZE (camss->vfe[k].line); j++) { + ret =media_create_pad_link ( + &camss->csid[i].subdev.entity, +MSM_CSID_PAD_SRC , + &camss->vfe[k].line[j].subdev.entity, +MSM_VFE_PAD_SINK , +0 ); +if (ret <0 ) { +dev_err (camss->dev, +"Failed to link %s->%s entities: %d\n" , + camss->csid[i].subdev.entity.name, + camss->vfe[k].line[j].subdev.entity.name, + ret); + goto err_link; + } + } + }return 0 ;@@ -884,8 +910,8 @@ static int camss_register_entities(struct camss *camss)for (i--; i >=0 ; i--)msm_vfe_unregister_entities (&camss->vfe[i]); -msm_ispif_unregister_entities (&camss->ispif); err_reg_ispif: +msm_ispif_unregister_entities (camss->ispif); i = camss->csid_num; err_reg_csid:@@ -916,7 +942,7 @@ static void camss_unregister_entities(struct camss *camss)for (i =0 ; i < camss->csid_num; i++)msm_csid_unregister_entity (&camss->csid[i]); -msm_ispif_unregister_entities (&camss->ispif); +msm_ispif_unregister_entities (camss->ispif);for (i =0 ; i < camss->vfe_num; i++)msm_vfe_unregister_entities (&camss->vfe[i]);@@ -1047,6 +1073,15 @@ static int camss_probe(struct platform_device *pdev) goto err_free; } +if (camss->version == CAMSS_8x16 || + camss->version == CAMSS_8x96) { + camss->ispif =devm_kcalloc (dev,1 ,sizeof (*camss->ispif),GFP_KERNEL ); +if (!camss->ispif) { + ret = -ENOMEM ; + goto err_free; + } + } + camss->vfe =devm_kcalloc (dev, camss->vfe_num,sizeof (*camss->vfe),GFP_KERNEL );if (!camss->vfe) {drivers/media/platform/qcom/camss/camss.h +1
-1@@ -79,7 +79,7 @@ struct camss {struct csiphy_device *csiphy;int csid_num;struct csid_device *csid; -struct ispif_device ispif; +struct ispif_device *ispif;int vfe_num;struct vfe_device *vfe;atomic_t ref_count;
PATCH v4 6/22 media: camss: Refactor VFE HW version support
In reply to Robert FossIn order to support Qualcomm ISP hardware architectures that diverge from older architectures, the VFE subdevice driver needs to be refactored to better abstract the different ISP architectures.
Gen1 represents the CAMSS ISP architecture. The ISP architecture developed after CAMSS, Titan, will be referred to as Gen2.
---
Changes since v1
- kernel test robot: Re-add chunk missing from vfe_output_update_pong_addr
- Andrey: Fix file name error
- Andrey: Change hardware version number in comment
- Changed copyright year to 2021 for camss-vfe-4-8.c
Changes since v3:
- Nicolas: Replace trace_printk() with dev_dbg()
- Removed spurious whitespace
drivers/media/platform/qcom/camss/Makefile | 2 + .../media/platform/qcom/camss/camss-vfe-4-1.c | 116 +- .../media/platform/qcom/camss/camss-vfe-4-7.c | 237 ++-- .../media/platform/qcom/camss/camss-vfe-4-8.c | 1164 +++++++++++++++++ .../platform/qcom/camss/camss-vfe-gen1.c | 763 +++++++++++ .../platform/qcom/camss/camss-vfe-gen1.h | 110 ++ drivers/media/platform/qcom/camss/camss-vfe.c | 770 +---------- drivers/media/platform/qcom/camss/camss-vfe.h | 113 +- 8 files changed, 2240 insertions(+), 1035 deletions(-) create mode 100644 drivers/media/platform/qcom/camss/camss-vfe-4-8.c create mode 100644 drivers/media/platform/qcom/camss/camss-vfe-gen1.c create mode 100644 drivers/media/platform/qcom/camss/camss-vfe-gen1.h
drivers/media/platform/qcom/camss/Makefile +2 -0
@@ -10,6 +10,8 @@ qcom-camss-objs += \ camss-ispif.o \ camss-vfe-4-1.o \ camss-vfe-4-7.o \ + camss-vfe-4-8.o \ + camss-vfe-gen1.o \ camss-vfe.o \ camss-video.o \
drivers/media/platform/qcom/camss/camss-vfe-4-1.c +47 -69
149 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-vfe-4-7.c +75 -162
331 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-vfe-4-8.c new file +1164 -0
1,164 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-vfe-gen1.c new file +763 -0
763 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-vfe-gen1.h new file +110 -0
110 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-vfe.c +16 -754
475 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-vfe.h +63 -50
113 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.27.0
Part of the diff is not shown here. View the raw message.
PATCH v4 7/22 media: camss: Add support for VFE hardware version Titan 170
In reply to Robert FossAdd register definitions for version 170 of the Titan architecture and implement support for the RDI output mode.
The RDI mode as opposed to the PIX output mode for the VFE unit does not support any ISP functionality. This means essentially only supporting dumping the output of the whatever the CSI decoder receives from the sensor.
For example will a sensor outputting YUV pixel format frames, only allow the VFE to dump those frames as they are received by the ISP to memory through the RDI interface.
---
Changes since v1:
- Andrey: Removed commented out chunk
- Remove left over WIP comments
drivers/media/platform/qcom/camss/Makefile | 1 + .../media/platform/qcom/camss/camss-vfe-170.c | 805 ++++++++++++++++++ drivers/media/platform/qcom/camss/camss-vfe.c | 59 +- drivers/media/platform/qcom/camss/camss-vfe.h | 25 +- .../media/platform/qcom/camss/camss-video.c | 100 +++ drivers/media/platform/qcom/camss/camss.c | 61 ++ 6 files changed, 1031 insertions(+), 20 deletions(-) create mode 100644 drivers/media/platform/qcom/camss/camss-vfe-170.c
drivers/media/platform/qcom/camss/Makefile +1 -0
@@ -11,6 +11,7 @@ qcom-camss-objs += \ camss-vfe-4-1.o \ camss-vfe-4-7.o \ camss-vfe-4-8.o \ + camss-vfe-170.o \ camss-vfe-gen1.o \ camss-vfe.o \ camss-video.o \
drivers/media/platform/qcom/camss/camss-vfe-170.c new file +805 -0
805 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-vfe.c +50 -9
95 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-vfe.h +14 -11
@@ -19,7 +19,6 @@#include "camss-video.h" #include "camss-vfe-gen1.h" -#define MSM_VFE_PAD_SINK 0#define MSM_VFE_PAD_SRC 1#define MSM_VFE_PADS_NUM 2
@@ -39,14 +38,14 @@#define to_vfe (ptr_line) \ container_of(vfe_line_array(ptr_line), struct vfe_device, line) -enum vfe_output_state {VFE_OUTPUT_OFF ,VFE_OUTPUT_RESERVED ,VFE_OUTPUT_SINGLE ,VFE_OUTPUT_CONTINUOUS ,VFE_OUTPUT_IDLE , -VFE_OUTPUT_STOPPING +VFE_OUTPUT_STOPPING , +VFE_OUTPUT_ON , };enum vfe_line_id {
@@ -72,6 +71,9 @@ struct vfe_output {int active_buf;int wait_sof; } gen1; +struct { +int active_num; + } gen2; };enum vfe_output_state state;unsigned int sequence;
@@ -169,14 +171,6 @@ void vfe_buf_add_pending(struct vfe_output *output, struct camss_buffer *buffer)struct camss_buffer *vfe_buf_get_pending (struct vfe_output *output); -/* -* vfe_disable - Disable streaming on VFE line -* @line: VFE line -* -* Return 0 on success or a negative error code otherwise -*/ -int vfe_disable (struct vfe_line *line); -int vfe_flush_buffers (struct camss_video *vid,enum vb2_buffer_state state);/*
@@ -191,8 +185,17 @@ int vfe_put_output(struct vfe_line *line);int vfe_release_wm (struct vfe_device *vfe,u8 wm);int vfe_reserve_wm (struct vfe_device *vfe,enum vfe_line_id line_id); +/* +* vfe_reset - Trigger reset on VFE module and wait to complete +* @vfe: VFE device +* +* Return 0 on success or a negative error code otherwise +*/ +int vfe_reset (struct vfe_device *vfe); +extern const struct vfe_hw_ops vfe_ops_4_1;extern const struct vfe_hw_ops vfe_ops_4_7;extern const struct vfe_hw_ops vfe_ops_4_8; +extern const struct vfe_hw_ops vfe_ops_170;#endif /* QC_MSM_CAMSS_VFE_H */
drivers/media/platform/qcom/camss/camss-video.c +100 -0
118 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss.c +61 -0
67 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH v4 07/22] media: camss: Add support for VFE hardware version Titan 170
Hi Robert,
Thank you for your patch!
In the patchset summary email you are saying that camss does not support the PIX interface for this generation of ISPs. But this patch still carries quite a lot of code handling the PIX interface. Like:
-----8<-----
#define REG_UPDATE_line_n(n) \
((n) == VFE_LINE_PIX ? 1 : REG_UPDATE_RDIn(n))
-----8<-----
for (i = VFE_LINE_RDI0; i <= VFE_LINE_PIX; i++)
if (status0 & STATUS_0_line_n_REG_UPDATE(i))
vfe->isr_ops.reg_update(vfe, i);
-----8<-----
switch (f->fmt.pix_mp.pixelformat) {
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV61:-----8<-----
- the NV pixel formats are only supported for PIX
-----8<-----
if (i == VFE_LINE_PIX) {
l->formats = formats_pix_845;
l->nformats = ARRAY_SIZE(formats_pix_845);
} else {
-----8<-----
static const struct camss_format_info formats_pix_845[] = {
{ MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV12, 1,
{ { 1, 1 } }, { { 2, 3 } }, { 8 } },
{ MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV12, 1,
{ { 1, 1 } }, { { 2, 3 } }, { 8 } },...
-----8<-----
Guess clearing the PIX related interrupt status bits is correct (provided that the driver doesn't try to really process them, and just clears these bits if they happen to be set for some reason). But the rest should be removed.
One more comment inline below.
Quoted 261 lines · Robert Foss
Add register definitions for version 170 of the Titan architecture and implement support for the RDI output mode.
The RDI mode as opposed to the PIX output mode for the VFE unit does not support any ISP functionality. This means essentially only supporting dumping the output of the whatever the CSI decoder receives from the sensor.
For example will a sensor outputting YUV pixel format frames, only allow the VFE to dump those frames as they are received by the ISP to memory through the RDI interface.
Signed-off-by Robert Foss <[email protected]>---
Changes since v1:
- Andrey: Removed commented out chunk
- Remove left over WIP commentsdrivers/media/platform/qcom/camss/Makefile | 1 + .../media/platform/qcom/camss/camss-vfe-170.c | 805 ++++++++++++++++++ drivers/media/platform/qcom/camss/camss-vfe.c | 59 +- drivers/media/platform/qcom/camss/camss-vfe.h | 25 +- .../media/platform/qcom/camss/camss-video.c | 100 +++ drivers/media/platform/qcom/camss/camss.c | 61 ++ 6 files changed, 1031 insertions(+), 20 deletions(-)create mode 100644
drivers/media/platform/qcom/camss/camss-vfe-170.cdrivers/media/platform/qcom/camss/Makefile +1
-0@@ -11,6 +11,7 @@ qcom-camss-objs += \ camss-vfe-4-1.o \ camss-vfe-4-7.o \ camss-vfe-4-8.o \ + camss-vfe-170.o \ camss-vfe-gen1.o \ camss-vfe.o \ camss-video.o \drivers/media/platform/qcom/camss/camss-vfe-170.c new file +214
-0@@ -0,0 +1,805 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* camss-vfe-4-7.c +* +* Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module v4.7 +* +* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. +* Copyright (C) 2015-2018 Linaro Ltd. +*/ + +#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/iopoll.h> + +#include "camss.h" +#include "camss-vfe.h" + +#define VFE_HW_VERSION (0x000) + +#define VFE_GLOBAL_RESET_CMD (0x018) +#define GLOBAL_RESET_CMD_CORE BIT(0) +#define GLOBAL_RESET_CMD_CAMIF BIT(1) +#define GLOBAL_RESET_CMD_BUS BIT(2) +#define GLOBAL_RESET_CMD_BUS_BDG BIT(3) +#define GLOBAL_RESET_CMD_REGISTER BIT(4) +#define GLOBAL_RESET_CMD_PM BIT(5) +#define GLOBAL_RESET_CMD_BUS_MISR BIT(6) +#define GLOBAL_RESET_CMD_TESTGEN BIT(7) +#define GLOBAL_RESET_CMD_DSP BIT(8) +#define GLOBAL_RESET_CMD_IDLE_CGC BIT(9) + +#define VFE_CORE_CFG (0x050) +#define CFG_PIXEL_PATTERN_YCBYCR (0x4) +#define CFG_PIXEL_PATTERN_YCRYCB (0x5) +#define CFG_PIXEL_PATTERN_CBYCRY (0x6) +#define CFG_PIXEL_PATTERN_CRYCBY (0x7) +#define CFG_COMPOSITE_REG_UPDATE_EN BIT(4) + +#define VFE_IRQ_CMD (0x058) +#define CMD_GLOBAL_CLEAR BIT(0) + +#define VFE_IRQ_MASK_0 (0x05c) +#define MASK_0_CAMIF_SOF BIT(0) +#define MASK_0_CAMIF_EOF BIT(1) +#define MASK_0_RDIn_REG_UPDATE (n) BIT((n) + 5) +#define MASK_0_line_n_REG_UPDATE (n) \ + ((n) == VFE_LINE_PIX ? \ + BIT(4) : MASK_0_RDIn_REG_UPDATE(n)) +#define MASK_0_IMAGE_MASTER_n_PING_PONG (n) BIT((n) + 8) +#define MASK_0_IMAGE_COMPOSITE_DONE_n (n) BIT((n) + 25) +#define MASK_0_RESET_ACK BIT(31) + +#define VFE_IRQ_MASK_1 (0x060) +#define MASK_1_CAMIF_ERROR BIT(0) +#define MASK_1_VIOLATION BIT(7) +#define MASK_1_BUS_BDG_HALT_ACK BIT(8) +#define MASK_1_IMAGE_MASTER_n_BUS_OVERFLOW (n) BIT((n) + 9) +#define MASK_1_RDIn_SOF (n) BIT((n) + 29) + +#define VFE_IRQ_CLEAR_0 (0x064) +#define VFE_IRQ_CLEAR_1 (0x068) + +#define VFE_IRQ_STATUS_0 (0x06c) +#define STATUS_0_CAMIF_SOF BIT(0) +#define STATUS_0_RDIn_REG_UPDATE (n) BIT((n) + 5) +#define STATUS_0_line_n_REG_UPDATE (n) \ + ((n) == VFE_LINE_PIX ? \ + BIT(4) : STATUS_0_RDIn_REG_UPDATE(n)) +#define STATUS_0_IMAGE_MASTER_n_PING_PONG (n) BIT((n) + 8) +#define STATUS_0_IMAGE_COMPOSITE_DONE_n (n) BIT((n) + 25) +#define STATUS_0_RESET_ACK BIT(31) + +#define VFE_IRQ_STATUS_1 (0x070) +#define STATUS_1_VIOLATION BIT(7) +#define STATUS_1_BUS_BDG_HALT_ACK BIT(8) +#define STATUS_1_RDIn_SOF (n) BIT((n) + 27) + +#define VFE_VIOLATION_STATUS (0x07c) + +#define VFE_CAMIF_CMD (0x478) +#define CMD_CLEAR_CAMIF_STATUS BIT(2) + +#define VFE_CAMIF_CFG (0x47c) +#define CFG_VSYNC_SYNC_EDGE (0) +#define VSYNC_ACTIVE_HIGH (0) +#define VSYNC_ACTIVE_LOW (1) +#define CFG_HSYNC_SYNC_EDGE (1) +#define HSYNC_ACTIVE_HIGH (0) +#define HSYNC_ACTIVE_LOW (1) +#define CFG_VFE_SUBSAMPLE_ENABLE BIT(4) +#define CFG_BUS_SUBSAMPLE_ENABLE BIT(5) +#define CFG_VFE_OUTPUT_EN BIT(6) +#define CFG_BUS_OUTPUT_EN BIT(7) +#define CFG_BINNING_EN BIT(9) +#define CFG_FRAME_BASED_EN BIT(10) +#define CFG_RAW_CROP_EN BIT(22) + +// XXX different, don't exist in TITAN register docs +#define VFE_0_CAMIF_FRAME_CFG 0x484 +#define VFE_0_CAMIF_WINDOW_WIDTH_CFG 0x488 +#define VFE_0_CAMIF_WINDOW_HEIGHT_CFG 0x48c +#define VFE_0_CAMIF_SUBSAMPLE_CFG 0x490 +#define VFE_0_CAMIF_IRQ_FRAMEDROP_PATTERN 0x498 +#define VFE_0_CAMIF_IRQ_SUBSAMPLE_PATTERN 0x49c +#define VFE_0_CAMIF_STATUS 0x4a4 +#define VFE_0_CAMIF_STATUS_HALT BIT(31) +#define CAMIF_TIMEOUT_SLEEP_US 1000 +#define CAMIF_TIMEOUT_ALL_US 1000000 + +#define VFE_REG_UPDATE_CMD (0x4ac) +#define REG_UPDATE_RDIn (n) BIT(1 + (n)) +#define REG_UPDATE_line_n (n) \ + ((n) == VFE_LINE_PIX ? 1 : REG_UPDATE_RDIn(n)) + + +#define VFE_BUS_IRQ_MASK (n) (0x2044 + (n) * 4) +#define VFE_BUS_IRQ_CLEAR (n) (0x2050 + (n) * 4) + +#define VFE_BUS_IRQ_STATUS (n) (0x205c + (n) * 4) +#define STATUS0_COMP_RESET_DONE BIT(0) +#define STATUS0_COMP_REG_UPDATE0_DONE BIT(1) +#define STATUS0_COMP_REG_UPDATE1_DONE BIT(2) +#define STATUS0_COMP_REG_UPDATE2_DONE BIT(3) +#define STATUS0_COMP_REG_UPDATE3_DONE BIT(4) +#define STATUS0_COMP_REG_UPDATE_DONE (n) BIT(n + 1) +#define STATUS0_COMP0_BUF_DONE BIT(5) +#define STATUS0_COMP1_BUF_DONE BIT(6) +#define STATUS0_COMP2_BUF_DONE BIT(7) +#define STATUS0_COMP3_BUF_DONE BIT(8) +#define STATUS0_COMP4_BUF_DONE BIT(9) +#define STATUS0_COMP5_BUF_DONE BIT(10) +#define STATUS0_COMP_BUF_DONE (n) BIT(n + 5) +#define STATUS0_COMP_ERROR BIT(11) +#define STATUS0_COMP_OVERWRITE BIT(12) +#define STATUS0_OVERFLOW BIT(13) +#define STATUS0_VIOLATION BIT(14) +/* WM_CLIENT_BUF_DONE defined for buffers 0:19 */ +#define STATUS1_WM_CLIENT_BUF_DONE (n) BIT(n) +#define STATUS1_EARLY_DONE BIT(24) +#define STATUS2_DUAL_COMP0_BUF_DONE BIT(0) +#define STATUS2_DUAL_COMP1_BUF_DONE BIT(1) +#define STATUS2_DUAL_COMP2_BUF_DONE BIT(2) +#define STATUS2_DUAL_COMP3_BUF_DONE BIT(3) +#define STATUS2_DUAL_COMP4_BUF_DONE BIT(4) +#define STATUS2_DUAL_COMP5_BUF_DONE BIT(5) +#define STATUS2_DUAL_COMP_BUF_DONE (n) BIT(n) +#define STATUS2_DUAL_COMP_ERROR BIT(6) +#define STATUS2_DUAL_COMP_OVERWRITE BIT(7) + +#define VFE_BUS_IRQ_CLEAR_GLOBAL (0x2068) + +#define VFE_BUS_WM_DEBUG_STATUS_CFG (0x226c) +#define DEBUG_STATUS_CFG_STATUS0 (n) BIT(n) +#define DEBUG_STATUS_CFG_STATUS1 (n) BIT(8+n) + +#define VFE_BUS_WM_ADDR_SYNC_FRAME_HEADER (0x2080) + +#define VFE_BUS_WM_ADDR_SYNC_NO_SYNC (0x2084) +#define BUS_VER2_MAX_CLIENTS (24) +#define WM_ADDR_NO_SYNC_DEFAULT_VAL \ + ((1 << BUS_VER2_MAX_CLIENTS) - 1) + +#define VFE_BUS_WM_CGC_OVERRIDE (0x200c) +#define WM_CGC_OVERRIDE_ALL (0xFFFFF) + +#define VFE_BUS_WM_TEST_BUS_CTRL (0x211c) + +#define VFE_BUS_WM_STATUS0 (n) (0x2200 + (n) * 0x100) +#define VFE_BUS_WM_STATUS1 (n) (0x2204 + (n) * 0x100) +#define VFE_BUS_WM_CFG (n) (0x2208 + (n) * 0x100) +#define WM_CFG_EN (0) +#define WM_CFG_MODE (1) +#define MODE_QCOM_PLAIN (0) +#define MODE_MIPI_RAW (1) +#define WM_CFG_VIRTUALFRAME (2) +#define VFE_BUS_WM_HEADER_ADDR (n) (0x220c + (n) * 0x100) +#define VFE_BUS_WM_HEADER_CFG (n) (0x2210 + (n) * 0x100) +#define VFE_BUS_WM_IMAGE_ADDR (n) (0x2214 + (n) * 0x100) +#define VFE_BUS_WM_IMAGE_ADDR_OFFSET (n) (0x2218 + (n) * 0x100) +#define VFE_BUS_WM_BUFFER_WIDTH_CFG (n) (0x221c + (n) * 0x100) +#define WM_BUFFER_DEFAULT_WIDTH (0xFF01) + +#define VFE_BUS_WM_BUFFER_HEIGHT_CFG (n) (0x2220 + (n) * 0x100) +#define VFE_BUS_WM_PACKER_CFG (n) (0x2224 + (n) * 0x100) + +#define VFE_BUS_WM_STRIDE (n) (0x2228 + (n) * 0x100) +#define WM_STRIDE_DEFAULT_STRIDE (0xFF01) + +#define VFE_BUS_WM_IRQ_SUBSAMPLE_PERIOD (n) (0x2248 + (n) * 0x100) +#define VFE_BUS_WM_IRQ_SUBSAMPLE_PATTERN (n) (0x224c + (n) * 0x100) +#define VFE_BUS_WM_FRAMEDROP_PERIOD (n) (0x2250 + (n) * 0x100) +#define VFE_BUS_WM_FRAMEDROP_PATTERN (n) (0x2254 + (n) * 0x100) +#define VFE_BUS_WM_FRAME_INC (n) (0x2258 + (n) * 0x100) +#define VFE_BUS_WM_BURST_LIMIT (n) (0x225c + (n) * 0x100) + + +static void vfe_hw_version_read (struct vfe_device *vfe,struct device *dev) +{ +u32 hw_version =readl_relaxed (vfe->base +VFE_HW_VERSION ); + +u32 gen = (hw_version >>28 ) &0xF ; +u32 rev = (hw_version >>16 ) &0xFFF ; +u32 step = hw_version &0xFFFF ; + +dev_err (dev,"VFE HW Version = %u.%u.%u\n" , gen, rev, step); +} + +static inline void vfe_reg_clr (struct vfe_device *vfe,u32 reg,u32 clr_bits) +{ +u32 bits =readl_relaxed (vfe->base + reg); + +writel_relaxed (bits & ~clr_bits, vfe->base + reg); +}
drivers/media/platform/qcom/camss/camss-vfe-170.c line 224
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-vfe-170.c new file +10
-0+ +static inline void vfe_reg_set (struct vfe_device *vfe,u32 reg,u32 set_bits) +{ +u32 bits =readl_relaxed (vfe->base + reg); + +writel_relaxed (bits | set_bits, vfe->base + reg); +} + +static void vfe_global_reset (struct vfe_device *vfe) +{
reset_bits are written to twice, the second write overwriting the first written value:
drivers/media/platform/qcom/camss/camss-vfe-170.c line 234
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-vfe-170.c new file +10
-0+u32 reset_bits =GLOBAL_RESET_CMD_IDLE_CGC | +GLOBAL_RESET_CMD_DSP | +GLOBAL_RESET_CMD_TESTGEN | +GLOBAL_RESET_CMD_BUS_MISR | +GLOBAL_RESET_CMD_PM | +GLOBAL_RESET_CMD_REGISTER | +GLOBAL_RESET_CMD_BUS_BDG | +GLOBAL_RESET_CMD_BUS | +GLOBAL_RESET_CMD_CAMIF | +GLOBAL_RESET_CMD_CORE ;
- 1st write
drivers/media/platform/qcom/camss/camss-vfe-170.c line 236
Quoted 1 line
drivers/media/platform/qcom/camss/camss-vfe-170.c new file +1
-0+ reset_bits =0x00003F9F ;
- 2nd write
Thanks,
Andrey
<snip>
Re: [PATCH v4 07/22] media: camss: Add support for VFE hardware version Titan 170
Quoted 9 lines · Andrey Konovalov
Hi Robert,
Thank you for your patch!
In the patchset summary email you are saying that camss does not support the PIX interface for this generation of ISPs. But this patch still carries quite a lot of code handling the PIX interface. Like:
Quoted 7 lines
-----8<-----
#define REG_UPDATE_line_n(n) \ ((n) == VFE_LINE_PIX ? 1 : REG_UPDATE_RDIn(n)) -----8<----- for (i = VFE_LINE_RDI0; i <= VFE_LINE_PIX; i++) if (status0 & STATUS_0_line_n_REG_UPDATE(i)) vfe->isr_ops.reg_update(vfe, i);
Thanks, I'll rework these defines for v5.
Quoted 8 lines
-----8<-----
switch (f->fmt.pix_mp.pixelformat) { case V4L2_PIX_FMT_NV12: case V4L2_PIX_FMT_NV21: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV61:-----8<-----
- the NV pixel formats are only supported for PIX
Ack, cutting this section out for v5.
Quoted 7 lines
-----8<-----
if (i == VFE_LINE_PIX) { l->formats = formats_pix_845; l->nformats = ARRAY_SIZE(formats_pix_845); } else {-----8<-----
Yep, removing this for v5.
Quoted 7 lines
static const struct camss_format_info formats_pix_845[] = { { MEDIA_BUS_FMT_YUYV8_1_5X8, V4L2_PIX_FMT_NV12, 1, { { 1, 1 } }, { { 2, 3 } }, { 8 } }, { MEDIA_BUS_FMT_YVYU8_1_5X8, V4L2_PIX_FMT_NV12, 1, { { 1, 1 } }, { { 2, 3 } }, { 8 } },...
-----8<-----
Removing this for v5.
Quoted 293 lines
Guess clearing the PIX related interrupt status bits is correct (provided that the driver doesn't try to really process them, and just clears these bits if they happen to be set for some reason). But the rest should be removed.
One more comment inline below.
Quoted 261 lines · Robert Foss
Add register definitions for version 170 of the Titan architecture and implement support for the RDI output mode.
The RDI mode as opposed to the PIX output mode for the VFE unit does not support any ISP functionality. This means essentially only supporting dumping the output of the whatever the CSI decoder receives from the sensor.
For example will a sensor outputting YUV pixel format frames, only allow the VFE to dump those frames as they are received by the ISP to memory through the RDI interface.
Signed-off-by Robert Foss <[email protected]>---
Changes since v1:
- Andrey: Removed commented out chunk
- Remove left over WIP commentsdrivers/media/platform/qcom/camss/Makefile | 1 + .../media/platform/qcom/camss/camss-vfe-170.c | 805 ++++++++++++++++++ drivers/media/platform/qcom/camss/camss-vfe.c | 59 +- drivers/media/platform/qcom/camss/camss-vfe.h | 25 +- .../media/platform/qcom/camss/camss-video.c | 100 +++ drivers/media/platform/qcom/camss/camss.c | 61 ++ 6 files changed, 1031 insertions(+), 20 deletions(-)create mode 100644
drivers/media/platform/qcom/camss/camss-vfe-170.cdrivers/media/platform/qcom/camss/Makefile +1
-0@@ -11,6 +11,7 @@ qcom-camss-objs += \ camss-vfe-4-1.o \ camss-vfe-4-7.o \ camss-vfe-4-8.o \ + camss-vfe-170.o \ camss-vfe-gen1.o \ camss-vfe.o \ camss-video.o \drivers/media/platform/qcom/camss/camss-vfe-170.c new file +214
-0@@ -0,0 +1,805 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* camss-vfe-4-7.c +* +* Qualcomm MSM Camera Subsystem - VFE (Video Front End) Module v4.7 +* +* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. +* Copyright (C) 2015-2018 Linaro Ltd. +*/ + +#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/iopoll.h> + +#include "camss.h" +#include "camss-vfe.h" + +#define VFE_HW_VERSION (0x000) + +#define VFE_GLOBAL_RESET_CMD (0x018) +#define GLOBAL_RESET_CMD_CORE BIT(0) +#define GLOBAL_RESET_CMD_CAMIF BIT(1) +#define GLOBAL_RESET_CMD_BUS BIT(2) +#define GLOBAL_RESET_CMD_BUS_BDG BIT(3) +#define GLOBAL_RESET_CMD_REGISTER BIT(4) +#define GLOBAL_RESET_CMD_PM BIT(5) +#define GLOBAL_RESET_CMD_BUS_MISR BIT(6) +#define GLOBAL_RESET_CMD_TESTGEN BIT(7) +#define GLOBAL_RESET_CMD_DSP BIT(8) +#define GLOBAL_RESET_CMD_IDLE_CGC BIT(9) + +#define VFE_CORE_CFG (0x050) +#define CFG_PIXEL_PATTERN_YCBYCR (0x4) +#define CFG_PIXEL_PATTERN_YCRYCB (0x5) +#define CFG_PIXEL_PATTERN_CBYCRY (0x6) +#define CFG_PIXEL_PATTERN_CRYCBY (0x7) +#define CFG_COMPOSITE_REG_UPDATE_EN BIT(4) + +#define VFE_IRQ_CMD (0x058) +#define CMD_GLOBAL_CLEAR BIT(0) + +#define VFE_IRQ_MASK_0 (0x05c) +#define MASK_0_CAMIF_SOF BIT(0) +#define MASK_0_CAMIF_EOF BIT(1) +#define MASK_0_RDIn_REG_UPDATE (n) BIT((n) + 5) +#define MASK_0_line_n_REG_UPDATE (n) \ + ((n) == VFE_LINE_PIX ? \ + BIT(4) : MASK_0_RDIn_REG_UPDATE(n)) +#define MASK_0_IMAGE_MASTER_n_PING_PONG (n) BIT((n) + 8) +#define MASK_0_IMAGE_COMPOSITE_DONE_n (n) BIT((n) + 25) +#define MASK_0_RESET_ACK BIT(31) + +#define VFE_IRQ_MASK_1 (0x060) +#define MASK_1_CAMIF_ERROR BIT(0) +#define MASK_1_VIOLATION BIT(7) +#define MASK_1_BUS_BDG_HALT_ACK BIT(8) +#define MASK_1_IMAGE_MASTER_n_BUS_OVERFLOW (n) BIT((n) + 9) +#define MASK_1_RDIn_SOF (n) BIT((n) + 29) + +#define VFE_IRQ_CLEAR_0 (0x064) +#define VFE_IRQ_CLEAR_1 (0x068) + +#define VFE_IRQ_STATUS_0 (0x06c) +#define STATUS_0_CAMIF_SOF BIT(0) +#define STATUS_0_RDIn_REG_UPDATE (n) BIT((n) + 5) +#define STATUS_0_line_n_REG_UPDATE (n) \ + ((n) == VFE_LINE_PIX ? \ + BIT(4) : STATUS_0_RDIn_REG_UPDATE(n)) +#define STATUS_0_IMAGE_MASTER_n_PING_PONG (n) BIT((n) + 8) +#define STATUS_0_IMAGE_COMPOSITE_DONE_n (n) BIT((n) + 25) +#define STATUS_0_RESET_ACK BIT(31) + +#define VFE_IRQ_STATUS_1 (0x070) +#define STATUS_1_VIOLATION BIT(7) +#define STATUS_1_BUS_BDG_HALT_ACK BIT(8) +#define STATUS_1_RDIn_SOF (n) BIT((n) + 27) + +#define VFE_VIOLATION_STATUS (0x07c) + +#define VFE_CAMIF_CMD (0x478) +#define CMD_CLEAR_CAMIF_STATUS BIT(2) + +#define VFE_CAMIF_CFG (0x47c) +#define CFG_VSYNC_SYNC_EDGE (0) +#define VSYNC_ACTIVE_HIGH (0) +#define VSYNC_ACTIVE_LOW (1) +#define CFG_HSYNC_SYNC_EDGE (1) +#define HSYNC_ACTIVE_HIGH (0) +#define HSYNC_ACTIVE_LOW (1) +#define CFG_VFE_SUBSAMPLE_ENABLE BIT(4) +#define CFG_BUS_SUBSAMPLE_ENABLE BIT(5) +#define CFG_VFE_OUTPUT_EN BIT(6) +#define CFG_BUS_OUTPUT_EN BIT(7) +#define CFG_BINNING_EN BIT(9) +#define CFG_FRAME_BASED_EN BIT(10) +#define CFG_RAW_CROP_EN BIT(22) + +// XXX different, don't exist in TITAN register docs +#define VFE_0_CAMIF_FRAME_CFG 0x484 +#define VFE_0_CAMIF_WINDOW_WIDTH_CFG 0x488 +#define VFE_0_CAMIF_WINDOW_HEIGHT_CFG 0x48c +#define VFE_0_CAMIF_SUBSAMPLE_CFG 0x490 +#define VFE_0_CAMIF_IRQ_FRAMEDROP_PATTERN 0x498 +#define VFE_0_CAMIF_IRQ_SUBSAMPLE_PATTERN 0x49c +#define VFE_0_CAMIF_STATUS 0x4a4 +#define VFE_0_CAMIF_STATUS_HALT BIT(31) +#define CAMIF_TIMEOUT_SLEEP_US 1000 +#define CAMIF_TIMEOUT_ALL_US 1000000 + +#define VFE_REG_UPDATE_CMD (0x4ac) +#define REG_UPDATE_RDIn (n) BIT(1 + (n)) +#define REG_UPDATE_line_n (n) \ + ((n) == VFE_LINE_PIX ? 1 : REG_UPDATE_RDIn(n)) + + +#define VFE_BUS_IRQ_MASK (n) (0x2044 + (n) * 4) +#define VFE_BUS_IRQ_CLEAR (n) (0x2050 + (n) * 4) + +#define VFE_BUS_IRQ_STATUS (n) (0x205c + (n) * 4) +#define STATUS0_COMP_RESET_DONE BIT(0) +#define STATUS0_COMP_REG_UPDATE0_DONE BIT(1) +#define STATUS0_COMP_REG_UPDATE1_DONE BIT(2) +#define STATUS0_COMP_REG_UPDATE2_DONE BIT(3) +#define STATUS0_COMP_REG_UPDATE3_DONE BIT(4) +#define STATUS0_COMP_REG_UPDATE_DONE (n) BIT(n + 1) +#define STATUS0_COMP0_BUF_DONE BIT(5) +#define STATUS0_COMP1_BUF_DONE BIT(6) +#define STATUS0_COMP2_BUF_DONE BIT(7) +#define STATUS0_COMP3_BUF_DONE BIT(8) +#define STATUS0_COMP4_BUF_DONE BIT(9) +#define STATUS0_COMP5_BUF_DONE BIT(10) +#define STATUS0_COMP_BUF_DONE (n) BIT(n + 5) +#define STATUS0_COMP_ERROR BIT(11) +#define STATUS0_COMP_OVERWRITE BIT(12) +#define STATUS0_OVERFLOW BIT(13) +#define STATUS0_VIOLATION BIT(14) +/* WM_CLIENT_BUF_DONE defined for buffers 0:19 */ +#define STATUS1_WM_CLIENT_BUF_DONE (n) BIT(n) +#define STATUS1_EARLY_DONE BIT(24) +#define STATUS2_DUAL_COMP0_BUF_DONE BIT(0) +#define STATUS2_DUAL_COMP1_BUF_DONE BIT(1) +#define STATUS2_DUAL_COMP2_BUF_DONE BIT(2) +#define STATUS2_DUAL_COMP3_BUF_DONE BIT(3) +#define STATUS2_DUAL_COMP4_BUF_DONE BIT(4) +#define STATUS2_DUAL_COMP5_BUF_DONE BIT(5) +#define STATUS2_DUAL_COMP_BUF_DONE (n) BIT(n) +#define STATUS2_DUAL_COMP_ERROR BIT(6) +#define STATUS2_DUAL_COMP_OVERWRITE BIT(7) + +#define VFE_BUS_IRQ_CLEAR_GLOBAL (0x2068) + +#define VFE_BUS_WM_DEBUG_STATUS_CFG (0x226c) +#define DEBUG_STATUS_CFG_STATUS0 (n) BIT(n) +#define DEBUG_STATUS_CFG_STATUS1 (n) BIT(8+n) + +#define VFE_BUS_WM_ADDR_SYNC_FRAME_HEADER (0x2080) + +#define VFE_BUS_WM_ADDR_SYNC_NO_SYNC (0x2084) +#define BUS_VER2_MAX_CLIENTS (24) +#define WM_ADDR_NO_SYNC_DEFAULT_VAL \ + ((1 << BUS_VER2_MAX_CLIENTS) - 1) + +#define VFE_BUS_WM_CGC_OVERRIDE (0x200c) +#define WM_CGC_OVERRIDE_ALL (0xFFFFF) + +#define VFE_BUS_WM_TEST_BUS_CTRL (0x211c) + +#define VFE_BUS_WM_STATUS0 (n) (0x2200 + (n) * 0x100) +#define VFE_BUS_WM_STATUS1 (n) (0x2204 + (n) * 0x100) +#define VFE_BUS_WM_CFG (n) (0x2208 + (n) * 0x100) +#define WM_CFG_EN (0) +#define WM_CFG_MODE (1) +#define MODE_QCOM_PLAIN (0) +#define MODE_MIPI_RAW (1) +#define WM_CFG_VIRTUALFRAME (2) +#define VFE_BUS_WM_HEADER_ADDR (n) (0x220c + (n) * 0x100) +#define VFE_BUS_WM_HEADER_CFG (n) (0x2210 + (n) * 0x100) +#define VFE_BUS_WM_IMAGE_ADDR (n) (0x2214 + (n) * 0x100) +#define VFE_BUS_WM_IMAGE_ADDR_OFFSET (n) (0x2218 + (n) * 0x100) +#define VFE_BUS_WM_BUFFER_WIDTH_CFG (n) (0x221c + (n) * 0x100) +#define WM_BUFFER_DEFAULT_WIDTH (0xFF01) + +#define VFE_BUS_WM_BUFFER_HEIGHT_CFG (n) (0x2220 + (n) * 0x100) +#define VFE_BUS_WM_PACKER_CFG (n) (0x2224 + (n) * 0x100) + +#define VFE_BUS_WM_STRIDE (n) (0x2228 + (n) * 0x100) +#define WM_STRIDE_DEFAULT_STRIDE (0xFF01) + +#define VFE_BUS_WM_IRQ_SUBSAMPLE_PERIOD (n) (0x2248 + (n) * 0x100) +#define VFE_BUS_WM_IRQ_SUBSAMPLE_PATTERN (n) (0x224c + (n) * 0x100) +#define VFE_BUS_WM_FRAMEDROP_PERIOD (n) (0x2250 + (n) * 0x100) +#define VFE_BUS_WM_FRAMEDROP_PATTERN (n) (0x2254 + (n) * 0x100) +#define VFE_BUS_WM_FRAME_INC (n) (0x2258 + (n) * 0x100) +#define VFE_BUS_WM_BURST_LIMIT (n) (0x225c + (n) * 0x100) + + +static void vfe_hw_version_read (struct vfe_device *vfe,struct device *dev) +{ +u32 hw_version =readl_relaxed (vfe->base +VFE_HW_VERSION ); + +u32 gen = (hw_version >>28 ) &0xF ; +u32 rev = (hw_version >>16 ) &0xFFF ; +u32 step = hw_version &0xFFFF ; + +dev_err (dev,"VFE HW Version = %u.%u.%u\n" , gen, rev, step); +} + +static inline void vfe_reg_clr (struct vfe_device *vfe,u32 reg,u32 clr_bits) +{ +u32 bits =readl_relaxed (vfe->base + reg); + +writel_relaxed (bits & ~clr_bits, vfe->base + reg); +}drivers/media/platform/qcom/camss/camss-vfe-170.c line 224
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-vfe-170.c new file +10
-0+ +static inline void vfe_reg_set (struct vfe_device *vfe,u32 reg,u32 set_bits) +{ +u32 bits =readl_relaxed (vfe->base + reg); + +writel_relaxed (bits | set_bits, vfe->base + reg); +} + +static void vfe_global_reset (struct vfe_device *vfe) +{
reset_bitsare written to twice, the second write overwriting the first written value:drivers/media/platform/qcom/camss/camss-vfe-170.c line 234
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-vfe-170.c new file +10
-0+u32 reset_bits =GLOBAL_RESET_CMD_IDLE_CGC | +GLOBAL_RESET_CMD_DSP | +GLOBAL_RESET_CMD_TESTGEN | +GLOBAL_RESET_CMD_BUS_MISR | +GLOBAL_RESET_CMD_PM | +GLOBAL_RESET_CMD_REGISTER | +GLOBAL_RESET_CMD_BUS_BDG | +GLOBAL_RESET_CMD_BUS | +GLOBAL_RESET_CMD_CAMIF | +GLOBAL_RESET_CMD_CORE ;
Quoted 5 lines
- 1st write
drivers/media/platform/qcom/camss/camss-vfe-170.c line 236
Quoted 1 line
drivers/media/platform/qcom/camss/camss-vfe-170.c new file +1
-0+ reset_bits =0x00003F9F ;- 2nd write
I found the documentation for these fields, and replaced the 2nd write by setting all of its bits in the 1st write.
Nice catch!
Quoted 5 lines
Thanks,
Andrey<snip>
PATCH v4 8/22 media: camss: Add missing format identifiers
In reply to Robert FossThe CSI-2 spec defines the following types:
- Data Type - Often abbreviated DT
- Decode Format - Often abbreviated as DF
- Encode Format
These definitions are as far as I can tell complete for CSI-2.
Additionally the Qualcomm internal type describing Plain Formats has been added. Plain formats describe the size of the pixels written by the RDI units to memory. PLAIN8 for example has the size 8 bits, and PLAIN32 32 bits. The appropriate Plain Format is determined by the Decode Format used. The smallest Plain Format that is able to contain a pixel of the used Decode Format is the appropriate one to use.
--- .../media/platform/qcom/camss/camss-csid.h | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+)
drivers/media/platform/qcom/camss/camss-csid.h +50 -0
@@ -21,6 +21,56 @@#define MSM_CSID_PAD_SRC 1#define MSM_CSID_PADS_NUM 2 +#define DATA_TYPE_EMBEDDED_DATA_8BIT 0x12 +#define DATA_TYPE_YUV420_8BIT 0x18 +#define DATA_TYPE_YUV420_10BIT 0x19 +#define DATA_TYPE_YUV420_8BIT_LEGACY 0x1a +#define DATA_TYPE_YUV420_8BIT_SHIFTED 0x1c/* Chroma Shifted Pixel Sampling */ +#define DATA_TYPE_YUV420_10BIT_SHIFTED 0x1d/* Chroma Shifted Pixel Sampling */ +#define DATA_TYPE_YUV422_8BIT 0x1e +#define DATA_TYPE_YUV422_10BIT 0x1f +#define DATA_TYPE_RGB444 0x20 +#define DATA_TYPE_RGB555 0x21 +#define DATA_TYPE_RGB565 0x22 +#define DATA_TYPE_RGB666 0x23 +#define DATA_TYPE_RGB888 0x24 +#define DATA_TYPE_RAW_24BIT 0x27 +#define DATA_TYPE_RAW_6BIT 0x28 +#define DATA_TYPE_RAW_7BIT 0x29 +#define DATA_TYPE_RAW_8BIT 0x2a +#define DATA_TYPE_RAW_10BIT 0x2b +#define DATA_TYPE_RAW_12BIT 0x2c +#define DATA_TYPE_RAW_14BIT 0x2d +#define DATA_TYPE_RAW_16BIT 0x2e +#define DATA_TYPE_RAW_20BIT 0x2f + +#define DECODE_FORMAT_UNCOMPRESSED_6_BIT 0x0 +#define DECODE_FORMAT_UNCOMPRESSED_8_BIT 0x1 +#define DECODE_FORMAT_UNCOMPRESSED_10_BIT 0x2 +#define DECODE_FORMAT_UNCOMPRESSED_12_BIT 0x3 +#define DECODE_FORMAT_UNCOMPRESSED_14_BIT 0x4 +#define DECODE_FORMAT_UNCOMPRESSED_16_BIT 0x5 +#define DECODE_FORMAT_UNCOMPRESSED_20_BIT 0x6 +#define DECODE_FORMAT_DPCM_10_6_10 0x7 +#define DECODE_FORMAT_DPCM_10_8_10 0x8 +#define DECODE_FORMAT_DPCM_12_6_12 0x9 +#define DECODE_FORMAT_DPCM_12_8_12 0xA +#define DECODE_FORMAT_DPCM_14_8_14 0xB +#define DECODE_FORMAT_DPCM_14_10_14 0xC +#define DECODE_FORMAT_USER_DEFINED 0xE +#define DECODE_FORMAT_PAYLOAD_ONLY 0xF + +#define ENCODE_FORMAT_RAW_8_BIT 0x1 +#define ENCODE_FORMAT_RAW_10_BIT 0x2 +#define ENCODE_FORMAT_RAW_12_BIT 0x3 +#define ENCODE_FORMAT_RAW_14_BIT 0x4 +#define ENCODE_FORMAT_RAW_16_BIT 0x5 + +#define PLAIN_FORMAT_PLAIN8 0x0/* supports DPCM, UNCOMPRESSED_6/8_BIT */ +#define PLAIN_FORMAT_PLAIN16 0x1/* supports DPCM, UNCOMPRESSED_10/16_BIT */ +#define PLAIN_FORMAT_PLAIN32 0x2/* supports UNCOMPRESSED_20_BIT */ + +enum csid_payload_mode {CSID_PAYLOAD_MODE_INCREMENTING =0 ,CSID_PAYLOAD_MODE_ALTERNATING_55_AA =1 ,
Signature · 1 line
2.27.0
PATCH v4 9/22 media: camss: Refactor CSID HW version support
In reply to Robert FossIn order to support Qualcomm ISP hardware architectures that diverge from older architectures, the CSID subdevice drivers needs to be refactored to better abstract the different ISP hardware architectures.
---
Changes since v1
- kernel test robot: Add missing include, interrupt.h
drivers/media/platform/qcom/camss/Makefile | 2 + .../platform/qcom/camss/camss-csid-4-1.c | 338 ++++++++++ .../platform/qcom/camss/camss-csid-4-7.c | 406 ++++++++++++ .../media/platform/qcom/camss/camss-csid.c | 616 +----------------- .../media/platform/qcom/camss/camss-csid.h | 126 +++- 5 files changed, 898 insertions(+), 590 deletions(-) create mode 100644 drivers/media/platform/qcom/camss/camss-csid-4-1.c create mode 100644 drivers/media/platform/qcom/camss/camss-csid-4-7.c
drivers/media/platform/qcom/camss/Makefile +2 -0
@@ -4,6 +4,8 @@ qcom-camss-objs += \ camss.o \ camss-csid.o \ + camss-csid-4-1.o \ + camss-csid-4-7.o \ camss-csiphy-2ph-1-0.o \ camss-csiphy-3ph-1-0.o \ camss-csiphy.o \
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +338 -0
338 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-csid-4-7.c new file +406 -0
406 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-csid.c +28 -588
733 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-csid.h +124 -2
169 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH v4 09/22] media: camss: Refactor CSID HW version support
Hi Robert,
Thank you for your patch!
Quoted 39 lines · Robert Foss
In order to support Qualcomm ISP hardware architectures that diverge from older architectures, the CSID subdevice drivers needs to be refactored to better abstract the different ISP hardware architectures.
Signed-off-by Robert Foss <[email protected]>---
Changes since v1
- kernel test robot: Add missing include,interrupt.hdrivers/media/platform/qcom/camss/Makefile | 2 + .../platform/qcom/camss/camss-csid-4-1.c | 338 ++++++++++ .../platform/qcom/camss/camss-csid-4-7.c | 406 ++++++++++++ .../media/platform/qcom/camss/camss-csid.c | 616 +----------------- .../media/platform/qcom/camss/camss-csid.h | 126 +++- 5 files changed, 898 insertions(+), 590 deletions(-)create mode 100644
drivers/media/platform/qcom/camss/camss-csid-4-1.ccreate mode 100644drivers/media/platform/qcom/camss/camss-csid-4-7.cdrivers/media/platform/qcom/camss/Makefile +2
-0@@ -4,6 +4,8 @@ qcom-camss-objs += \ camss.o \ camss-csid.o \ + camss-csid-4-1.o \ + camss-csid-4-7.o \ camss-csiphy-2ph-1-0.o \ camss-csiphy-3ph-1-0.o \ camss-csiphy.o \drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +0
-0
drivers/media/platform/qcom/camss/camss-csid-4-1.c line 8
Quoted 8 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +8
-0@@ -0,0 +1,338 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* camss-csid-4-1.c +* +* Qualcomm MSM Camera Subsystem - CSID (CSI Decoder) Module +* +* Copyright (C) 2020 Linaro Ltd. +*/
Why is this extra space before each #include below:
drivers/media/platform/qcom/camss/camss-csid-4-1.c line 13
Quoted 5 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +5
-0+#include <linux/completion.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/of.h>
^
here?
Quoted 31 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +31
-0+ +#include "camss-csid.h" +#include "camss.h" + +#define CAMSS_CSID_HW_VERSION 0x0 +#define CAMSS_CSID_CORE_CTRL_0 0x004 +#define CAMSS_CSID_CORE_CTRL_1 0x008 +#define CAMSS_CSID_RST_CMD 0x00c +#define CAMSS_CSID_CID_LUT_VC_n (n) (0x010 + 0x4 * (n)) +#define CAMSS_CSID_CID_n_CFG (n) (0x020 + 0x4 * (n)) +#define CAMSS_CSID_CID_n_CFG_ISPIF_EN BIT(0) +#define CAMSS_CSID_CID_n_CFG_RDI_EN BIT(1) +#define CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT 4 +#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_8 (0 << 8) +#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16 (1 << 8) +#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB (0 << 9) +#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_MSB (1 << 9) +#define CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP (0 << 10) +#define CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING (1 << 10) +#define CAMSS_CSID_IRQ_CLEAR_CMD 0x060 +#define CAMSS_CSID_IRQ_MASK 0x064 +#define CAMSS_CSID_IRQ_STATUS 0x068 +#define CAMSS_CSID_TG_CTRL 0x0a0 +#define CAMSS_CSID_TG_CTRL_DISABLE 0xa06436 +#define CAMSS_CSID_TG_CTRL_ENABLE 0xa06437 +#define CAMSS_CSID_TG_VC_CFG 0x0a4 +#define CAMSS_CSID_TG_VC_CFG_H_BLANKING 0x3ff +#define CAMSS_CSID_TG_VC_CFG_V_BLANKING 0x7f +#define CAMSS_CSID_TG_DT_n_CGG_0 (n) (0x0ac + 0xc * (n)) +#define CAMSS_CSID_TG_DT_n_CGG_1 (n) (0x0b0 + 0xc * (n)) +#define CAMSS_CSID_TG_DT_n_CGG_2 (n) (0x0b4 + 0xc * (n))
drivers/media/platform/qcom/camss/camss-csid-4-1.c line 54
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +10
-0+ + +enum csid_testgen_pattern { +TESTGEN_PATTERN_INCREMENTING =0 , +TESTGEN_PATTERN_ALTERNATING_55_AA =1 , +TESTGEN_PATTERN_ALL_ZEROES =2 , +TESTGEN_PATTERN_ALL_ONES =3 , +TESTGEN_PATTERN_RANDOM =4 , +TESTGEN_PATTERN_USER_SPECIFIED =5 , +};
- this enum is unused.
Thanks,
Andrey
Quoted 1,627 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +284
-0+ +static const struct csid_format csid_formats[] = { + { +MEDIA_BUS_FMT_UYVY8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_VYUY8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_YUYV8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_YVYU8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_SBGGR8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_Y10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, +}; + +static void csid_configure_stream (struct csid_device *csid,u8 enable) +{ +struct csid_testgen_config *tg = &csid->testgen; +u32 val; + +if (enable) { +struct v4l2_mbus_framefmt *input_format; +const struct csid_format *format; +u8 vc =0 ;/* Virtual Channel 0 */ +u8 cid = vc *4 ;/* id of Virtual Channel and Data Type set */ +u8 dt_shift; + +if (tg->enabled) { +/* Config Test Generator */ +u32 num_lines, num_bytes_per_line; + + input_format = &csid->fmt[MSM_CSID_PAD_SRC ]; + format =csid_get_fmt_entry (csid->formats, csid->nformats, + input_format->code); + num_bytes_per_line = input_format->width * format->bpp * format->spp /8 ; + num_lines = input_format->height; + +/* 31:24 V blank, 23:13 H blank, 3:2 num of active DT */ +/* 1:0 VC */ + val = ((CAMSS_CSID_TG_VC_CFG_V_BLANKING &0xff ) <<24 ) | + ((CAMSS_CSID_TG_VC_CFG_H_BLANKING &0x7ff ) <<13 ); +writel_relaxed (val, csid->base +CAMSS_CSID_TG_VC_CFG ); + +/* 28:16 bytes per lines, 12:0 num of lines */ + val = ((num_bytes_per_line &0x1fff ) <<16 ) | + (num_lines &0x1fff ); +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_0 (0 )); + +/* 5:0 data type */ + val = format->data_type; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_1 (0 )); + +/* 2:0 output test pattern */ + val = tg->mode; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_2 (0 )); + }else { +struct csid_phy_config *phy = &csid->phy; + + input_format = &csid->fmt[MSM_CSID_PAD_SINK ]; + format =csid_get_fmt_entry (csid->formats, csid->nformats, + input_format->code); + + val = phy->lane_cnt -1 ; + val |= phy->lane_assign <<4 ; + +writel_relaxed (val, csid->base +CAMSS_CSID_CORE_CTRL_0 ); + + val = phy->csiphy_id <<17 ; + val |=0x9 ; + +writel_relaxed (val, csid->base +CAMSS_CSID_CORE_CTRL_1 ); + } + +/* Config LUT */ + + dt_shift = (cid %4 ) *8 ; + val =readl_relaxed (csid->base +CAMSS_CSID_CID_LUT_VC_n (vc)); + val &= ~(0xff << dt_shift); + val |= format->data_type << dt_shift; +writel_relaxed (val, csid->base +CAMSS_CSID_CID_LUT_VC_n (vc)); + + val = CAMSS_CSID_CID_n_CFG_ISPIF_EN; + val |= CAMSS_CSID_CID_n_CFG_RDI_EN; + val |= format->decode_format << CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT; + val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP; +writel_relaxed (val, csid->base +CAMSS_CSID_CID_n_CFG (cid)); + +if (tg->enabled) { + val =CAMSS_CSID_TG_CTRL_ENABLE ; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_CTRL ); + } + }else { +if (tg->enabled) { + val =CAMSS_CSID_TG_CTRL_DISABLE ; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_CTRL ); + } + } +} + +static int csid_configure_testgen_pattern (struct csid_device *csid,s32 val) +{ +s32 regval = val -1 ; + +if (regval >0 || regval <=CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_1 ) + csid->testgen.mode = regval; + +return 0 ; +} + +static u32 csid_hw_version (struct csid_device *csid) +{ +u32 hw_version =readl_relaxed (csid->base +CAMSS_CSID_HW_VERSION ); + +dev_dbg (csid->camss->dev,"CSID HW Version = 0x%08x\n" , hw_version); + +return hw_version; +} + +static irqreturn_t csid_isr (int irq,void *dev) +{ +struct csid_device *csid = dev; +u32 value; + + value =readl_relaxed (csid->base +CAMSS_CSID_IRQ_STATUS ); +writel_relaxed (value, csid->base +CAMSS_CSID_IRQ_CLEAR_CMD ); + +if ((value >>11 ) &0x1 ) +complete (&csid->reset_complete); + +return IRQ_HANDLED ; +} + +static int csid_reset (struct csid_device *csid) +{ +unsigned long time; + +reinit_completion (&csid->reset_complete); + +writel_relaxed (0x7fff , csid->base +CAMSS_CSID_RST_CMD ); + + time =wait_for_completion_timeout (&csid->reset_complete, +msecs_to_jiffies (CSID_RESET_TIMEOUT_MS )); +if (!time) { +dev_err (csid->camss->dev,"CSID reset timeout\n" ); +return -EIO ; + } + +return 0 ; +} + +static u32 csid_src_pad_code (struct csid_device *csid,u32 sink_code, +unsigned int match_format_idx,u32 match_code) +{ +if (match_format_idx >0 ) +return 0 ; + +return sink_code; +} + +static void csid_subdev_init (struct csid_device *csid) +{ + csid->formats = csid_formats; + csid->nformats =ARRAY_SIZE (csid_formats); + csid->testgen.modes = csid_testgen_modes; + csid->testgen.nmodes =CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_1 ; +} + +const struct csid_hw_ops csid_ops_4_1 = { + .configure_stream = csid_configure_stream, + .configure_testgen_pattern = csid_configure_testgen_pattern, + .hw_version = csid_hw_version, + .isr = csid_isr, + .reset = csid_reset, + .src_pad_code = csid_src_pad_code, + .subdev_init = csid_subdev_init, +};drivers/media/platform/qcom/camss/camss-csid-4-7.c new file +406
-0@@ -0,0 +1,406 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* camss-csid-4-7.c +* +* Qualcomm MSM Camera Subsystem - CSID (CSI Decoder) Module +* +* Copyright (C) 2020 Linaro Ltd. +*/ +#include <linux/completion.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/of.h> + +#include "camss-csid.h" +#include "camss.h" + +#define CAMSS_CSID_HW_VERSION 0x0 +#define CAMSS_CSID_CORE_CTRL_0 0x004 +#define CAMSS_CSID_CORE_CTRL_1 0x008 +#define CAMSS_CSID_RST_CMD 0x010 +#define CAMSS_CSID_CID_LUT_VC_n (n) (0x014 + 0x4 * (n)) +#define CAMSS_CSID_CID_n_CFG (n) (0x024 + 0x4 * (n)) +#define CAMSS_CSID_CID_n_CFG_ISPIF_EN BIT(0) +#define CAMSS_CSID_CID_n_CFG_RDI_EN BIT(1) +#define CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT 4 +#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_8 (0 << 8) +#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16 (1 << 8) +#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB (0 << 9) +#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_MSB (1 << 9) +#define CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP (0 << 10) +#define CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING (1 << 10) +#define CAMSS_CSID_IRQ_CLEAR_CMD 0x064 +#define CAMSS_CSID_IRQ_MASK 0x068 +#define CAMSS_CSID_IRQ_STATUS 0x06c +#define CAMSS_CSID_TG_CTRL 0x0a8 +#define CAMSS_CSID_TG_CTRL_DISABLE 0xa06436 +#define CAMSS_CSID_TG_CTRL_ENABLE 0xa06437 +#define CAMSS_CSID_TG_VC_CFG 0x0ac +#define CAMSS_CSID_TG_VC_CFG_H_BLANKING 0x3ff +#define CAMSS_CSID_TG_VC_CFG_V_BLANKING 0x7f +#define CAMSS_CSID_TG_DT_n_CGG_0 (n) (0x0b4 + 0xc * (n)) +#define CAMSS_CSID_TG_DT_n_CGG_1 (n) (0x0b8 + 0xc * (n)) +#define CAMSS_CSID_TG_DT_n_CGG_2 (n) (0x0bc + 0xc * (n)) + + +static const struct csid_format csid_formats[] = { + { +MEDIA_BUS_FMT_UYVY8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_VYUY8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_YUYV8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_YVYU8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_SBGGR8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR14_1X14 , +DATA_TYPE_RAW_14BIT , +DECODE_FORMAT_UNCOMPRESSED_14_BIT , +14 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG14_1X14 , +DATA_TYPE_RAW_14BIT , +DECODE_FORMAT_UNCOMPRESSED_14_BIT , +14 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG14_1X14 , +DATA_TYPE_RAW_14BIT , +DECODE_FORMAT_UNCOMPRESSED_14_BIT , +14 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB14_1X14 , +DATA_TYPE_RAW_14BIT , +DECODE_FORMAT_UNCOMPRESSED_14_BIT , +14 , +1 , + }, + { +MEDIA_BUS_FMT_Y10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, +}; + +static void csid_configure_stream (struct csid_device *csid,u8 enable) +{ +struct csid_testgen_config *tg = &csid->testgen; +u32 sink_code = csid->fmt[MSM_CSID_PAD_SINK ].code; +u32 src_code = csid->fmt[MSM_CSID_PAD_SRC ].code; +u32 val; + +if (enable) { +struct v4l2_mbus_framefmt *input_format; +const struct csid_format *format; +u8 vc =0 ;/* Virtual Channel 0 */ +u8 cid = vc *4 ;/* id of Virtual Channel and Data Type set */ +u8 dt_shift; + +if (tg->enabled) { +/* Config Test Generator */ +u32 num_bytes_per_line, num_lines; + + input_format = &csid->fmt[MSM_CSID_PAD_SRC ]; + format =csid_get_fmt_entry (csid->formats, csid->nformats, + input_format->code); + num_bytes_per_line = input_format->width * format->bpp * format->spp /8 ; + num_lines = input_format->height; + +/* 31:24 V blank, 23:13 H blank, 3:2 num of active DT */ +/* 1:0 VC */ + val = ((CAMSS_CSID_TG_VC_CFG_V_BLANKING &0xff ) <<24 ) | + ((CAMSS_CSID_TG_VC_CFG_H_BLANKING &0x7ff ) <<13 ); +writel_relaxed (val, csid->base +CAMSS_CSID_TG_VC_CFG ); + +/* 28:16 bytes per lines, 12:0 num of lines */ + val = ((num_bytes_per_line &0x1fff ) <<16 ) | + (num_lines &0x1fff ); +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_0 (0 )); + +/* 5:0 data type */ + val = format->data_type; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_1 (0 )); + +/* 2:0 output test pattern */ + val = tg->mode; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_2 (0 )); + }else { +struct csid_phy_config *phy = &csid->phy; + + input_format = &csid->fmt[MSM_CSID_PAD_SINK ]; + format =csid_get_fmt_entry (csid->formats, csid->nformats, + input_format->code); + + val = phy->lane_cnt -1 ; + val |= phy->lane_assign <<4 ; + +writel_relaxed (val, csid->base +CAMSS_CSID_CORE_CTRL_0 ); + + val = phy->csiphy_id <<17 ; + val |=0x9 ; + +writel_relaxed (val, csid->base +CAMSS_CSID_CORE_CTRL_1 ); + } + +/* Config LUT */ + + dt_shift = (cid %4 ) *8 ; + + val =readl_relaxed (csid->base +CAMSS_CSID_CID_LUT_VC_n (vc)); + val &= ~(0xff << dt_shift); + val |= format->data_type << dt_shift; +writel_relaxed (val, csid->base +CAMSS_CSID_CID_LUT_VC_n (vc)); + + val = CAMSS_CSID_CID_n_CFG_ISPIF_EN; + val |= CAMSS_CSID_CID_n_CFG_RDI_EN; + val |= format->decode_format << CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT; + val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP; + +if ((sink_code ==MEDIA_BUS_FMT_SBGGR10_1X10 && + src_code ==MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE ) || + (sink_code ==MEDIA_BUS_FMT_Y10_1X10 && + src_code ==MEDIA_BUS_FMT_Y10_2X8_PADHI_LE )) { + val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING; + val |= CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16; + val |= CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB; + } + +writel_relaxed (val, csid->base +CAMSS_CSID_CID_n_CFG (cid)); + +if (tg->enabled) { + val =CAMSS_CSID_TG_CTRL_ENABLE ; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_CTRL ); + } + }else { +if (tg->enabled) { + val =CAMSS_CSID_TG_CTRL_DISABLE ; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_CTRL ); + } + } +} + +static int csid_configure_testgen_pattern (struct csid_device *csid,s32 val) +{ +s32 regval = val -1 ; + +if (regval >0 || regval <=CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_7 ) + csid->testgen.mode = regval; + +return 0 ; +} + +static u32 csid_hw_version (struct csid_device *csid) +{ +u32 hw_version =readl_relaxed (csid->base +CAMSS_CSID_HW_VERSION ); + +dev_dbg (csid->camss->dev,"CSID HW Version = 0x%08x\n" , hw_version); + +return hw_version; +} + +/* +* isr - CSID module interrupt service routine +* @irq: Interrupt line +* @dev: CSID device +* +* Return IRQ_HANDLED on success +*/ +static irqreturn_t csid_isr (int irq,void *dev) +{ +struct csid_device *csid = dev; +u32 value; + + value =readl_relaxed (csid->base +CAMSS_CSID_IRQ_STATUS ); +writel_relaxed (value, csid->base +CAMSS_CSID_IRQ_CLEAR_CMD ); + +if ((value >>11 ) &0x1 ) +complete (&csid->reset_complete); + +return IRQ_HANDLED ; +} + +/* +* csid_reset - Trigger reset on CSID module and wait to complete +* @csid: CSID device +* +* Return 0 on success or a negative error code otherwise +*/ +static int csid_reset (struct csid_device *csid) +{ +unsigned long time; + +reinit_completion (&csid->reset_complete); + +writel_relaxed (0x7fff , csid->base +CAMSS_CSID_RST_CMD ); + + time =wait_for_completion_timeout (&csid->reset_complete, +msecs_to_jiffies (CSID_RESET_TIMEOUT_MS )); +if (!time) { +dev_err (csid->camss->dev,"CSID reset timeout\n" ); +return -EIO ; + } + +return 0 ; +} + +static u32 csid_src_pad_code (struct csid_device *csid,u32 sink_code, +unsigned int match_format_idx,u32 match_code) +{ +switch (sink_code) { +case MEDIA_BUS_FMT_SBGGR10_1X10 : + { +u32 src_code[] = { +MEDIA_BUS_FMT_SBGGR10_1X10 , +MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE , + }; + +return csid_find_code (src_code,ARRAY_SIZE (src_code), + match_format_idx, match_code); + } +case MEDIA_BUS_FMT_Y10_1X10 : + { +u32 src_code[] = { +MEDIA_BUS_FMT_Y10_1X10 , +MEDIA_BUS_FMT_Y10_2X8_PADHI_LE , + }; + +return csid_find_code (src_code,ARRAY_SIZE (src_code), + match_format_idx, match_code); + } +default : +if (match_format_idx >0 ) +return 0 ; + +return sink_code; + } +} + +static void csid_subdev_init (struct csid_device *csid) +{ + csid->formats = csid_formats; + csid->nformats =ARRAY_SIZE (csid_formats); + csid->testgen.modes = csid_testgen_modes; + csid->testgen.nmodes =CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_7 ; +} + +const struct csid_hw_ops csid_ops_4_7 = { + .configure_stream = csid_configure_stream, + .configure_testgen_pattern = csid_configure_testgen_pattern, + .hw_version = csid_hw_version, + .isr = csid_isr, + .reset = csid_reset, + .src_pad_code = csid_src_pad_code, + .subdev_init = csid_subdev_init, +};drivers/media/platform/qcom/camss/camss-csid.c +28
-588@@ -26,405 +26,35 @@#define MSM_CSID_NAME "msm_csid" -#define CAMSS_CSID_HW_VERSION 0x0 -#define CAMSS_CSID_CORE_CTRL_0 0x004 -#define CAMSS_CSID_CORE_CTRL_1 0x008 -#define CAMSS_CSID_RST_CMD (v) ((v) == CAMSS_8x16 ? 0x00c : 0x010) -#define CAMSS_CSID_CID_LUT_VC_n (v, n) \ - (((v) == CAMSS_8x16 ? 0x010 : 0x014) + 0x4 * (n)) -#define CAMSS_CSID_CID_n_CFG (v, n) \ - (((v) == CAMSS_8x16 ? 0x020 : 0x024) + 0x4 * (n)) -#define CAMSS_CSID_CID_n_CFG_ISPIF_EN BIT(0) -#define CAMSS_CSID_CID_n_CFG_RDI_EN BIT(1) -#define CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT 4 -#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_8 (0 << 8) -#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16 (1 << 8) -#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB (0 << 9) -#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_MSB (1 << 9) -#define CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP (0 << 10) -#define CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING (1 << 10) -#define CAMSS_CSID_IRQ_CLEAR_CMD (v) ((v) == CAMSS_8x16 ? 0x060 : 0x064) -#define CAMSS_CSID_IRQ_MASK (v) ((v) == CAMSS_8x16 ? 0x064 : 0x068) -#define CAMSS_CSID_IRQ_STATUS (v) ((v) == CAMSS_8x16 ? 0x068 : 0x06c) -#define CAMSS_CSID_TG_CTRL (v) ((v) == CAMSS_8x16 ? 0x0a0 : 0x0a8) -#define CAMSS_CSID_TG_CTRL_DISABLE 0xa06436 -#define CAMSS_CSID_TG_CTRL_ENABLE 0xa06437 -#define CAMSS_CSID_TG_VC_CFG (v) ((v) == CAMSS_8x16 ? 0x0a4 : 0x0ac) -#define CAMSS_CSID_TG_VC_CFG_H_BLANKING 0x3ff -#define CAMSS_CSID_TG_VC_CFG_V_BLANKING 0x7f -#define CAMSS_CSID_TG_DT_n_CGG_0 (v, n) \ - (((v) == CAMSS_8x16 ? 0x0ac : 0x0b4) + 0xc * (n)) -#define CAMSS_CSID_TG_DT_n_CGG_1 (v, n) \ - (((v) == CAMSS_8x16 ? 0x0b0 : 0x0b8) + 0xc * (n)) -#define CAMSS_CSID_TG_DT_n_CGG_2 (v, n) \ - (((v) == CAMSS_8x16 ? 0x0b4 : 0x0bc) + 0xc * (n)) - -#define DATA_TYPE_EMBEDDED_DATA_8BIT 0x12 -#define DATA_TYPE_YUV422_8BIT 0x1e -#define DATA_TYPE_RAW_6BIT 0x28 -#define DATA_TYPE_RAW_8BIT 0x2a -#define DATA_TYPE_RAW_10BIT 0x2b -#define DATA_TYPE_RAW_12BIT 0x2c -#define DATA_TYPE_RAW_14BIT 0x2d - -#define DECODE_FORMAT_UNCOMPRESSED_6_BIT 0x0 -#define DECODE_FORMAT_UNCOMPRESSED_8_BIT 0x1 -#define DECODE_FORMAT_UNCOMPRESSED_10_BIT 0x2 -#define DECODE_FORMAT_UNCOMPRESSED_12_BIT 0x3 -#define DECODE_FORMAT_UNCOMPRESSED_14_BIT 0x8 - -#define CSID_RESET_TIMEOUT_MS 500 - -struct csid_format { -u32 code; -u8 data_type; -u8 decode_format; -u8 bpp; -u8 spp;/* bus samples per pixel */ -}; - -static const struct csid_format csid_formats_8x16[] = { - { -MEDIA_BUS_FMT_UYVY8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_VYUY8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_YUYV8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_YVYU8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_SBGGR8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_Y10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, -}; - -static const struct csid_format csid_formats_8x96[] = { - { -MEDIA_BUS_FMT_UYVY8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_VYUY8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_YUYV8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_YVYU8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_SBGGR8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR14_1X14 , -DATA_TYPE_RAW_14BIT , -DECODE_FORMAT_UNCOMPRESSED_14_BIT , -14 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG14_1X14 , -DATA_TYPE_RAW_14BIT , -DECODE_FORMAT_UNCOMPRESSED_14_BIT , -14 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG14_1X14 , -DATA_TYPE_RAW_14BIT , -DECODE_FORMAT_UNCOMPRESSED_14_BIT , -14 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB14_1X14 , -DATA_TYPE_RAW_14BIT , -DECODE_FORMAT_UNCOMPRESSED_14_BIT , -14 , -1 , - }, - { -MEDIA_BUS_FMT_Y10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, -}; -static u32 csid_find_code (u32 *code,unsigned int n_code, -unsigned int index,u32 req_code) +u32 csid_find_code (u32 *codes,unsigned int ncodes, +unsigned int match_format_idx,u32 match_code) {int i; -if (!req_code && (index >= n_code)) +if (!match_code && (match_format_idx >= ncodes))return 0 ; -for (i =0 ; i < n_code; i++) -if (req_code) { -if (req_code == code[i]) -return req_code; +for (i =0 ; i < ncodes; i++) +if (match_code) { +if (codes[i] == match_code) +return match_code; }else { -if (i == index) -return code[i]; - } - -return code[0 ]; -} - -static u32 csid_src_pad_code (struct csid_device *csid,u32 sink_code, -unsigned int index,u32 src_req_code) -{ -if (csid->camss->version == CAMSS_8x16) { -if (index >0 ) -return 0 ; - -return sink_code; - }else if (csid->camss->version == CAMSS_8x96 || - csid->camss->version ==CAMSS_660 ) { -switch (sink_code) { -case MEDIA_BUS_FMT_SBGGR10_1X10 : - { -u32 src_code[] = { -MEDIA_BUS_FMT_SBGGR10_1X10 , -MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE , - }; - -return csid_find_code (src_code,ARRAY_SIZE (src_code), - index, src_req_code); - } -case MEDIA_BUS_FMT_Y10_1X10 : - { -u32 src_code[] = { -MEDIA_BUS_FMT_Y10_1X10 , -MEDIA_BUS_FMT_Y10_2X8_PADHI_LE , - }; - -return csid_find_code (src_code,ARRAY_SIZE (src_code), - index, src_req_code); +if (i == match_format_idx) +return codes[i]; } -default : -if (index >0 ) -return 0 ; -return sink_code; - } - }else { -return 0 ; - } +return codes[0 ]; } -static const struct csid_format *csid_get_fmt_entry ( +const struct csid_format *csid_get_fmt_entry (const struct csid_format *formats, -unsigned int nformat, +unsigned int nformats,u32 code) {unsigned int i; -for (i =0 ; i < nformat; i++) +for (i =0 ; i < nformats; i++)if (code == formats[i].code)return &formats[i];@@ -433,28 +63,6 @@ static const struct csid_format *csid_get_fmt_entry(return &formats[0 ]; } -/* -* csid_isr - CSID module interrupt handler -* @irq: Interrupt line -* @dev: CSID device -* -* Return IRQ_HANDLED on success -*/ -static irqreturn_t csid_isr (int irq,void *dev) -{ -struct csid_device *csid = dev; -enum camss_version ver = csid->camss->version; -u32 value; - - value =readl_relaxed (csid->base +CAMSS_CSID_IRQ_STATUS (ver)); -writel_relaxed (value, csid->base +CAMSS_CSID_IRQ_CLEAR_CMD (ver)); - -if ((value >>11 ) &0x1 ) -complete (&csid->reset_complete); - -return IRQ_HANDLED ; -} -/* * csid_set_clock_rates - Calculate and set clock rates on CSID module * @csiphy: CSID device @@ -521,31 +129,6 @@ static int csid_set_clock_rates(struct csid_device *csid)return 0 ; } -/* -* csid_reset - Trigger reset on CSID module and wait to complete -* @csid: CSID device -* -* Return 0 on success or a negative error code otherwise -*/ -static int csid_reset (struct csid_device *csid) -{ -unsigned long time; - -reinit_completion (&csid->reset_complete); - -writel_relaxed (0x7fff , csid->base + -CAMSS_CSID_RST_CMD (csid->camss->version)); - - time =wait_for_completion_timeout (&csid->reset_complete, -msecs_to_jiffies (CSID_RESET_TIMEOUT_MS )); -if (!time) { -dev_err (csid->camss->dev,"CSID reset timeout\n" ); -return -EIO ; - } - -return 0 ; -} -/* * csid_set_power - Power on/off CSID module * @sd: CSID V4L2 subdevice @@ -560,8 +143,6 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)int ret;if (on) { -u32 hw_version; - ret =pm_runtime_get_sync (dev);if (ret <0 ) {pm_runtime_put_sync (dev);@@ -590,7 +171,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)enable_irq (csid->irq); - ret =csid_reset (csid); + ret = csid->ops->reset (csid);if (ret <0 ) {disable_irq (csid->irq);camss_disable_clocks (csid->nclocks, csid->clock);@@ -599,8 +180,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)return ret; } - hw_version =readl_relaxed (csid->base +CAMSS_CSID_HW_VERSION ); -dev_dbg (dev,"CSID HW Version = 0x%08x\n" , hw_version); + csid->ops->hw_version (csid); }else {disable_irq (csid->irq);camss_disable_clocks (csid->nclocks, csid->clock);@@ -623,16 +203,9 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)static int csid_set_stream (struct v4l2_subdev *sd,int enable) {struct csid_device *csid =v4l2_get_subdevdata (sd); -struct csid_testgen_config *tg = &csid->testgen; -enum camss_version ver = csid->camss->version; -u32 val; +int ret;if (enable) { -u8 vc =0 ;/* Virtual Channel 0 */ -u8 cid = vc *4 ;/* id of Virtual Channel and Data Type set */ -u8 dt, dt_shift, df; -int ret; - ret =v4l2_ctrl_handler_setup (&csid->ctrls);if (ret <0 ) { dev_err(csid->camss->dev,@@ -640,116 +213,13 @@ static int csid_set_stream(struct v4l2_subdev *sd, int enable)return ret; } -if (!tg->enabled && +if (!csid->testgen.enabled && !media_entity_remote_pad (&csid->pads[MSM_CSID_PAD_SINK ]))return -ENOLINK ; - -if (tg->enabled) { -/* Config Test Generator */ -struct v4l2_mbus_framefmt *f = - &csid->fmt[MSM_CSID_PAD_SRC ]; -const struct csid_format *format =csid_get_fmt_entry ( - csid->formats, csid->nformats, f->code); -u32 num_bytes_per_line = - f->width * format->bpp * format->spp /8 ; -u32 num_lines = f->height; - -/* 31:24 V blank, 23:13 H blank, 3:2 num of active DT */ -/* 1:0 VC */ - val = ((CAMSS_CSID_TG_VC_CFG_V_BLANKING &0xff ) <<24 ) | - ((CAMSS_CSID_TG_VC_CFG_H_BLANKING &0x7ff ) <<13 ); -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_VC_CFG (ver)); - -/* 28:16 bytes per lines, 12:0 num of lines */ - val = ((num_bytes_per_line &0x1fff ) <<16 ) | - (num_lines &0x1fff ); -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_DT_n_CGG_0 (ver,0 )); - - dt = format->data_type; - -/* 5:0 data type */ - val = dt; -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_DT_n_CGG_1 (ver,0 )); - -/* 2:0 output test pattern */ - val = tg->payload_mode; -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_DT_n_CGG_2 (ver,0 )); - - df = format->decode_format; - }else { -struct v4l2_mbus_framefmt *f = - &csid->fmt[MSM_CSID_PAD_SINK ]; -const struct csid_format *format =csid_get_fmt_entry ( - csid->formats, csid->nformats, f->code); -struct csid_phy_config *phy = &csid->phy; - - val = phy->lane_cnt -1 ; - val |= phy->lane_assign <<4 ; - -writel_relaxed (val, - csid->base +CAMSS_CSID_CORE_CTRL_0 ); - - val = phy->csiphy_id <<17 ; - val |=0x9 ; - -writel_relaxed (val, - csid->base +CAMSS_CSID_CORE_CTRL_1 ); - - dt = format->data_type; - df = format->decode_format; - } - -/* Config LUT */ - - dt_shift = (cid %4 ) *8 ; - - val =readl_relaxed (csid->base + -CAMSS_CSID_CID_LUT_VC_n (ver, vc)); - val &= ~(0xff << dt_shift); - val |= dt << dt_shift; -writel_relaxed (val, csid->base + -CAMSS_CSID_CID_LUT_VC_n (ver, vc)); - - val = CAMSS_CSID_CID_n_CFG_ISPIF_EN; - val |= CAMSS_CSID_CID_n_CFG_RDI_EN; - val |= df << CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT; - val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP; - -if (csid->camss->version == CAMSS_8x96 || - csid->camss->version ==CAMSS_660 ) { -u32 sink_code = csid->fmt[MSM_CSID_PAD_SINK ].code; -u32 src_code = csid->fmt[MSM_CSID_PAD_SRC ].code; - -if ((sink_code ==MEDIA_BUS_FMT_SBGGR10_1X10 && - src_code ==MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE ) || - (sink_code ==MEDIA_BUS_FMT_Y10_1X10 && - src_code ==MEDIA_BUS_FMT_Y10_2X8_PADHI_LE )) { - val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING; - val |= CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16; - val |= CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB; - } - } - -writel_relaxed (val, csid->base + -CAMSS_CSID_CID_n_CFG (ver, cid)); - -if (tg->enabled) { - val =CAMSS_CSID_TG_CTRL_ENABLE ; -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_CTRL (ver)); - } - }else { -if (tg->enabled) { - val =CAMSS_CSID_TG_CTRL_DISABLE ; -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_CTRL (ver)); - } } + csid->ops->configure_stream (csid, enable); +return 0 ; }@@ -818,7 +288,7 @@ static void csid_try_format(struct csid_device *csid, *fmt = *__csid_get_format (csid, cfg,MSM_CSID_PAD_SINK , which); - fmt->code =csid_src_pad_code (csid, fmt->code,0 , code); + fmt->code = csid->ops->src_pad_code (csid, fmt->code,0 , code); }else {/* Test generator is enabled, set format on source */ /* pad to allow test generator usage */ @@ -868,7 +338,7 @@ static int csid_enum_mbus_code(struct v4l2_subdev *sd,MSM_CSID_PAD_SINK , code->which); - code->code =csid_src_pad_code (csid, sink_fmt->code, + code->code = csid->ops->src_pad_code (csid, sink_fmt->code, code->index,0 );if (!code->code)return -EINVAL ;@@ -1004,15 +474,6 @@ static int csid_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)return csid_set_format (sd, fh ? fh->pad :NULL , &format); } -static const char *const csid_test_pattern_menu[] = { -"Disabled" , -"Incrementing" , -"Alternating 0x55/0xAA" , -"All Zeros 0x00" , -"All Ones 0xFF" , -"Pseudo-random Data" , -}; -/* * csid_set_test_pattern - Set test generator's pattern mode * @csid: CSID device @@ -1030,25 +491,7 @@ static int csid_set_test_pattern(struct csid_device *csid, s32 value) tg->enabled = !!value; -switch (value) { -case 1 : - tg->payload_mode =CSID_PAYLOAD_MODE_INCREMENTING ; -break ; -case 2 : - tg->payload_mode =CSID_PAYLOAD_MODE_ALTERNATING_55_AA ; -break ; -case 3 : - tg->payload_mode =CSID_PAYLOAD_MODE_ALL_ZEROES ; -break ; -case 4 : - tg->payload_mode =CSID_PAYLOAD_MODE_ALL_ONES ; -break ; -case 5 : - tg->payload_mode =CSID_PAYLOAD_MODE_RANDOM ; -break ; - } - -return 0 ; +return csid->ops->configure_testgen_pattern (csid, value); }/* @@ -1097,17 +540,14 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, csid->id = id;if (camss->version == CAMSS_8x16) { - csid->formats = csid_formats_8x16; - csid->nformats = -ARRAY_SIZE (csid_formats_8x16); + csid->ops = &csid_ops_4_1; }else if (camss->version == CAMSS_8x96 || camss->version ==CAMSS_660 ) { - csid->formats = csid_formats_8x96; - csid->nformats = -ARRAY_SIZE (csid_formats_8x96); + csid->ops = &csid_ops_4_7; }else {return -EINVAL ; } + csid->ops->subdev_init (csid);/* Memory */ @@ -1130,7 +570,7 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, csid->irq = r->start;snprintf (csid->irq_name,sizeof (csid->irq_name),"%s_%s%d" ,dev_name (dev),MSM_CSID_NAME , csid->id); - ret =devm_request_irq (dev, csid->irq, csid_isr, + ret =devm_request_irq (dev, csid->irq, csid->ops->isr,IRQF_TRIGGER_RISING , csid->irq_name, csid);if (ret <0 ) {dev_err (dev,"request_irq failed: %d\n" , ret);@@ -1341,8 +781,8 @@ int msm_csid_register_entity(struct csid_device *csid, csid->testgen_mode =v4l2_ctrl_new_std_menu_items (&csid->ctrls, &csid_ctrl_ops,V4L2_CID_TEST_PATTERN , -ARRAY_SIZE (csid_test_pattern_menu) -1 ,0 ,0 , - csid_test_pattern_menu); + csid->testgen.nmodes,0 ,0 , + csid->testgen.modes);if (csid->ctrls.error) {dev_err (dev,"Failed to init ctrl: %d\n" , csid->ctrls.error);drivers/media/platform/qcom/camss/camss-csid.h +124
-2@@ -11,6 +11,7 @@#define QC_MSM_CAMSS_CSID_H #include <linux/clk.h> +#include <linux/interrupt.h> #include <media/media-entity.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> @@ -70,19 +71,50 @@#define PLAIN_FORMAT_PLAIN16 0x1/* supports DPCM, UNCOMPRESSED_10/16_BIT */ #define PLAIN_FORMAT_PLAIN32 0x2/* supports UNCOMPRESSED_20_BIT */ +#define CSID_RESET_TIMEOUT_MS 500 -enum csid_payload_mode { + +enum csid_testgen_mode {CSID_PAYLOAD_MODE_INCREMENTING =0 ,CSID_PAYLOAD_MODE_ALTERNATING_55_AA =1 ,CSID_PAYLOAD_MODE_ALL_ZEROES =2 ,CSID_PAYLOAD_MODE_ALL_ONES =3 ,CSID_PAYLOAD_MODE_RANDOM =4 ,CSID_PAYLOAD_MODE_USER_SPECIFIED =5 , +CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_1 =5 , +CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_7 =5 , +CSID_PAYLOAD_MODE_COMPLEX_PATTERN =6 , +CSID_PAYLOAD_MODE_COLOR_BOX =7 , +CSID_PAYLOAD_MODE_COLOR_BARS =8 , +CSID_PAYLOAD_MODE_MAX_SUPPORTED_170 =8 , +}; + +static const char *const csid_testgen_modes[] = { +"Disabled" , +"Incrementing" , +"Alternating 0x55/0xAA" , +"All Zeros 0x00" , +"All Ones 0xFF" , +"Pseudo-random Data" , +"User Specified" , +"Complex pattern" , +"Color box" , +"Color bars" , +}; + +struct csid_format { +u32 code; +u8 data_type; +u8 decode_format; +u8 bpp; +u8 spp;/* bus samples per pixel */ };struct csid_testgen_config { +enum csid_testgen_mode mode; +const char *const *modes; +u8 nmodes;u8 enabled; -enum csid_payload_mode payload_mode; };struct csid_phy_config {@@ -91,6 +123,65 @@ struct csid_phy_config {u32 lane_assign; }; +struct csid_device ; + +struct csid_hw_ops { +/* +* configure_stream - Configures and starts CSID input stream +* @csid: CSID device +*/ +void (*configure_stream)(struct csid_device *csid,u8 enable); + +/* +* configure_testgen_pattern - Validates and configures output pattern mode +* of test pattern generator +* @csid: CSID device +*/ +int (*configure_testgen_pattern)(struct csid_device *csid,s32 val); + +/* +* hw_version - Read hardware version register from hardware +* @csid: CSID device +*/ +u32 (*hw_version)(struct csid_device *csid); + +/* +* isr - CSID module interrupt service routine +* @irq: Interrupt line +* @dev: CSID device +* +* Return IRQ_HANDLED on success +*/ +irqreturn_t (*isr)(int irq,void *dev); + +/* +* reset - Trigger reset on CSID module and wait to complete +* @csid: CSID device +* +* Return 0 on success or a negative error code otherwise +*/ +int (*reset)(struct csid_device *csid); + +/* +* src_pad_code - Pick an output/src format based on the input/sink format +* @csid: CSID device +* @sink_code: The sink format of the input +* @match_format_idx: Request preferred index, as defined by subdevice csid_format. +* Set @match_code to 0 if used. +* @match_code: Request preferred code, set @match_format_idx to 0 if used +* +* Return 0 on failure or src format code otherwise +*/ +u32 (*src_pad_code)(struct csid_device *csid,u32 sink_code, +unsigned int match_format_idx,u32 match_code); + +/* +* subdev_init - Initialize CSID device according for hardware revision +* @csid: CSID device +*/ +void (*subdev_init)(struct csid_device *csid); +}; +struct csid_device {struct camss *camss;u8 id;@@ -110,10 +201,37 @@ struct csid_device {struct v4l2_ctrl *testgen_mode;const struct csid_format *formats;unsigned int nformats; +const struct csid_hw_ops *ops; };struct resources ; + +/* +* csid_find_code - Find a format code in an array using array index or format code +* @codes: Array of format codes +* @ncodes: Length of @code array +* @req_format_idx: Request preferred index, as defined by subdevice csid_format. +* Set @match_code to 0 if used. +* @match_code: Request preferred code, set @req_format_idx to 0 if used +* +* Return 0 on failure or format code otherwise +*/ +u32 csid_find_code (u32 *codes,unsigned int ncode, +unsigned int match_format_idx,u32 match_code); + +/* +* csid_get_fmt_entry - Find csid_format entry with matching format code +* @formats: Array of format csid_format entries +* @nformats: Length of @nformats array +* @code: Desired format code +* +* Return formats[0] on failure to find code +*/ +const struct csid_format *csid_get_fmt_entry (const struct csid_format *formats, +unsigned int nformats, +u32 code); +int msm_csid_subdev_init (struct camss *camss,struct csid_device *csid,const struct resources *res,u8 id);@@ -124,4 +242,8 @@ void msm_csid_unregister_entity(struct csid_device *csid);void msm_csid_get_csid_id (struct media_entity *entity,u8 *id); + +extern const struct csid_hw_ops csid_ops_4_1; +extern const struct csid_hw_ops csid_ops_4_7; +#endif /* QC_MSM_CAMSS_CSID_H */
Re: [PATCH v4 09/22] media: camss: Refactor CSID HW version support
Thanks Andrey!
Quoted 47 lines · Andrey Konovalov
Hi Robert,
Thank you for your patch!
Quoted 41 lines · Robert Foss
In order to support Qualcomm ISP hardware architectures that diverge from older architectures, the CSID subdevice drivers needs to be refactored to better abstract the different ISP hardware architectures.
Signed-off-by Robert Foss <[email protected]>---
Changes since v1
- kernel test robot: Add missing include,interrupt.hdrivers/media/platform/qcom/camss/Makefile | 2 + .../platform/qcom/camss/camss-csid-4-1.c | 338 ++++++++++ .../platform/qcom/camss/camss-csid-4-7.c | 406 ++++++++++++ .../media/platform/qcom/camss/camss-csid.c | 616 +----------------- .../media/platform/qcom/camss/camss-csid.h | 126 +++- 5 files changed, 898 insertions(+), 590 deletions(-)create mode 100644
drivers/media/platform/qcom/camss/camss-csid-4-1.ccreate mode 100644drivers/media/platform/qcom/camss/camss-csid-4-7.cdrivers/media/platform/qcom/camss/Makefile +2
-0@@ -4,6 +4,8 @@ qcom-camss-objs += \ camss.o \ camss-csid.o \ + camss-csid-4-1.o \ + camss-csid-4-7.o \ camss-csiphy-2ph-1-0.o \ camss-csiphy-3ph-1-0.o \ camss-csiphy.o \drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +2
-0@@ -0,0 +1,338 @@ +// SPDX-License-Identifier: GPL-2.0 +/*
Quoted 8 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c line 8
Quoted 6 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +6
-0+* camss-csid-4-1.c +* +* Qualcomm MSM Camera Subsystem - CSID (CSI Decoder) Module +* +* Copyright (C) 2020 Linaro Ltd. +*/ Why is this extra space before each #include below:
Good Q, I suspect an editor stabbed me in the back. Fixing this in v5.
Quoted 44 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c line 13
Quoted 6 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +5
-0+#include <linux/completion.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/of.h> ^ here?Quoted 35 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +35
-0+ +#include "camss-csid.h" +#include "camss.h" + +#define CAMSS_CSID_HW_VERSION 0x0 +#define CAMSS_CSID_CORE_CTRL_0 0x004 +#define CAMSS_CSID_CORE_CTRL_1 0x008 +#define CAMSS_CSID_RST_CMD 0x00c +#define CAMSS_CSID_CID_LUT_VC_n (n) (0x010 + 0x4 * (n)) +#define CAMSS_CSID_CID_n_CFG (n) (0x020 + 0x4 * (n)) +#define CAMSS_CSID_CID_n_CFG_ISPIF_EN BIT(0) +#define CAMSS_CSID_CID_n_CFG_RDI_EN BIT(1) +#define CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT 4 +#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_8 (0 << 8) +#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16 (1 << 8) +#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB (0 << 9) +#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_MSB (1 << 9) +#define CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP (0 << 10) +#define CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING (1 << 10) +#define CAMSS_CSID_IRQ_CLEAR_CMD 0x060 +#define CAMSS_CSID_IRQ_MASK 0x064 +#define CAMSS_CSID_IRQ_STATUS 0x068 +#define CAMSS_CSID_TG_CTRL 0x0a0 +#define CAMSS_CSID_TG_CTRL_DISABLE 0xa06436 +#define CAMSS_CSID_TG_CTRL_ENABLE 0xa06437 +#define CAMSS_CSID_TG_VC_CFG 0x0a4 +#define CAMSS_CSID_TG_VC_CFG_H_BLANKING 0x3ff +#define CAMSS_CSID_TG_VC_CFG_V_BLANKING 0x7f +#define CAMSS_CSID_TG_DT_n_CGG_0 (n) (0x0ac + 0xc * (n)) +#define CAMSS_CSID_TG_DT_n_CGG_1 (n) (0x0b0 + 0xc * (n)) +#define CAMSS_CSID_TG_DT_n_CGG_2 (n) (0x0b4 + 0xc * (n)) + + +enum csid_testgen_pattern { +TESTGEN_PATTERN_INCREMENTING =0 ,
Quoted 8 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c line 54
Quoted 6 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +6
-0+TESTGEN_PATTERN_ALTERNATING_55_AA =1 , +TESTGEN_PATTERN_ALL_ZEROES =2 , +TESTGEN_PATTERN_ALL_ONES =3 , +TESTGEN_PATTERN_RANDOM =4 , + TESTGEN_PATTERN_USER_SPECIFIED = 5, +};- this enum is unused.
Ack, fixing in v5.
Quoted 1,631 lines
Thanks,
AndreyQuoted 1,627 lines
drivers/media/platform/qcom/camss/camss-csid-4-1.c new file +284
-0+ +static const struct csid_format csid_formats[] = { + { +MEDIA_BUS_FMT_UYVY8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_VYUY8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_YUYV8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_YVYU8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_SBGGR8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_Y10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, +}; + +static void csid_configure_stream (struct csid_device *csid,u8 enable) +{ +struct csid_testgen_config *tg = &csid->testgen; +u32 val; + +if (enable) { +struct v4l2_mbus_framefmt *input_format; +const struct csid_format *format; +u8 vc =0 ;/* Virtual Channel 0 */ +u8 cid = vc *4 ;/* id of Virtual Channel and Data Type set */ +u8 dt_shift; + +if (tg->enabled) { +/* Config Test Generator */ +u32 num_lines, num_bytes_per_line; + + input_format = &csid->fmt[MSM_CSID_PAD_SRC ]; + format =csid_get_fmt_entry (csid->formats, csid->nformats, + input_format->code); + num_bytes_per_line = input_format->width * format->bpp * format->spp /8 ; + num_lines = input_format->height; + +/* 31:24 V blank, 23:13 H blank, 3:2 num of active DT */ +/* 1:0 VC */ + val = ((CAMSS_CSID_TG_VC_CFG_V_BLANKING &0xff ) <<24 ) | + ((CAMSS_CSID_TG_VC_CFG_H_BLANKING &0x7ff ) <<13 ); +writel_relaxed (val, csid->base +CAMSS_CSID_TG_VC_CFG ); + +/* 28:16 bytes per lines, 12:0 num of lines */ + val = ((num_bytes_per_line &0x1fff ) <<16 ) | + (num_lines &0x1fff ); +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_0 (0 )); + +/* 5:0 data type */ + val = format->data_type; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_1 (0 )); + +/* 2:0 output test pattern */ + val = tg->mode; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_2 (0 )); + }else { +struct csid_phy_config *phy = &csid->phy; + + input_format = &csid->fmt[MSM_CSID_PAD_SINK ]; + format =csid_get_fmt_entry (csid->formats, csid->nformats, + input_format->code); + + val = phy->lane_cnt -1 ; + val |= phy->lane_assign <<4 ; + +writel_relaxed (val, csid->base +CAMSS_CSID_CORE_CTRL_0 ); + + val = phy->csiphy_id <<17 ; + val |=0x9 ; + +writel_relaxed (val, csid->base +CAMSS_CSID_CORE_CTRL_1 ); + } + +/* Config LUT */ + + dt_shift = (cid %4 ) *8 ; + val =readl_relaxed (csid->base +CAMSS_CSID_CID_LUT_VC_n (vc)); + val &= ~(0xff << dt_shift); + val |= format->data_type << dt_shift; +writel_relaxed (val, csid->base +CAMSS_CSID_CID_LUT_VC_n (vc)); + + val = CAMSS_CSID_CID_n_CFG_ISPIF_EN; + val |= CAMSS_CSID_CID_n_CFG_RDI_EN; + val |= format->decode_format << CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT; + val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP; +writel_relaxed (val, csid->base +CAMSS_CSID_CID_n_CFG (cid)); + +if (tg->enabled) { + val =CAMSS_CSID_TG_CTRL_ENABLE ; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_CTRL ); + } + }else { +if (tg->enabled) { + val =CAMSS_CSID_TG_CTRL_DISABLE ; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_CTRL ); + } + } +} + +static int csid_configure_testgen_pattern (struct csid_device *csid,s32 val) +{ +s32 regval = val -1 ; + +if (regval >0 || regval <=CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_1 ) + csid->testgen.mode = regval; + +return 0 ; +} + +static u32 csid_hw_version (struct csid_device *csid) +{ +u32 hw_version =readl_relaxed (csid->base +CAMSS_CSID_HW_VERSION ); + +dev_dbg (csid->camss->dev,"CSID HW Version = 0x%08x\n" , hw_version); + +return hw_version; +} + +static irqreturn_t csid_isr (int irq,void *dev) +{ +struct csid_device *csid = dev; +u32 value; + + value =readl_relaxed (csid->base +CAMSS_CSID_IRQ_STATUS ); +writel_relaxed (value, csid->base +CAMSS_CSID_IRQ_CLEAR_CMD ); + +if ((value >>11 ) &0x1 ) +complete (&csid->reset_complete); + +return IRQ_HANDLED ; +} + +static int csid_reset (struct csid_device *csid) +{ +unsigned long time; + +reinit_completion (&csid->reset_complete); + +writel_relaxed (0x7fff , csid->base +CAMSS_CSID_RST_CMD ); + + time =wait_for_completion_timeout (&csid->reset_complete, +msecs_to_jiffies (CSID_RESET_TIMEOUT_MS )); +if (!time) { +dev_err (csid->camss->dev,"CSID reset timeout\n" ); +return -EIO ; + } + +return 0 ; +} + +static u32 csid_src_pad_code (struct csid_device *csid,u32 sink_code, +unsigned int match_format_idx,u32 match_code) +{ +if (match_format_idx >0 ) +return 0 ; + +return sink_code; +} + +static void csid_subdev_init (struct csid_device *csid) +{ + csid->formats = csid_formats; + csid->nformats =ARRAY_SIZE (csid_formats); + csid->testgen.modes = csid_testgen_modes; + csid->testgen.nmodes =CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_1 ; +} + +const struct csid_hw_ops csid_ops_4_1 = { + .configure_stream = csid_configure_stream, + .configure_testgen_pattern = csid_configure_testgen_pattern, + .hw_version = csid_hw_version, + .isr = csid_isr, + .reset = csid_reset, + .src_pad_code = csid_src_pad_code, + .subdev_init = csid_subdev_init, +};drivers/media/platform/qcom/camss/camss-csid-4-7.c new file +406
-0@@ -0,0 +1,406 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* camss-csid-4-7.c +* +* Qualcomm MSM Camera Subsystem - CSID (CSI Decoder) Module +* +* Copyright (C) 2020 Linaro Ltd. +*/ +#include <linux/completion.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/of.h> + +#include "camss-csid.h" +#include "camss.h" + +#define CAMSS_CSID_HW_VERSION 0x0 +#define CAMSS_CSID_CORE_CTRL_0 0x004 +#define CAMSS_CSID_CORE_CTRL_1 0x008 +#define CAMSS_CSID_RST_CMD 0x010 +#define CAMSS_CSID_CID_LUT_VC_n (n) (0x014 + 0x4 * (n)) +#define CAMSS_CSID_CID_n_CFG (n) (0x024 + 0x4 * (n)) +#define CAMSS_CSID_CID_n_CFG_ISPIF_EN BIT(0) +#define CAMSS_CSID_CID_n_CFG_RDI_EN BIT(1) +#define CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT 4 +#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_8 (0 << 8) +#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16 (1 << 8) +#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB (0 << 9) +#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_MSB (1 << 9) +#define CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP (0 << 10) +#define CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING (1 << 10) +#define CAMSS_CSID_IRQ_CLEAR_CMD 0x064 +#define CAMSS_CSID_IRQ_MASK 0x068 +#define CAMSS_CSID_IRQ_STATUS 0x06c +#define CAMSS_CSID_TG_CTRL 0x0a8 +#define CAMSS_CSID_TG_CTRL_DISABLE 0xa06436 +#define CAMSS_CSID_TG_CTRL_ENABLE 0xa06437 +#define CAMSS_CSID_TG_VC_CFG 0x0ac +#define CAMSS_CSID_TG_VC_CFG_H_BLANKING 0x3ff +#define CAMSS_CSID_TG_VC_CFG_V_BLANKING 0x7f +#define CAMSS_CSID_TG_DT_n_CGG_0 (n) (0x0b4 + 0xc * (n)) +#define CAMSS_CSID_TG_DT_n_CGG_1 (n) (0x0b8 + 0xc * (n)) +#define CAMSS_CSID_TG_DT_n_CGG_2 (n) (0x0bc + 0xc * (n)) + + +static const struct csid_format csid_formats[] = { + { +MEDIA_BUS_FMT_UYVY8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_VYUY8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_YUYV8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_YVYU8_2X8 , +DATA_TYPE_YUV422_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +2 , + }, + { +MEDIA_BUS_FMT_SBGGR8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB8_1X8 , +DATA_TYPE_RAW_8BIT , +DECODE_FORMAT_UNCOMPRESSED_8_BIT , +8 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB12_1X12 , +DATA_TYPE_RAW_12BIT , +DECODE_FORMAT_UNCOMPRESSED_12_BIT , +12 , +1 , + }, + { +MEDIA_BUS_FMT_SBGGR14_1X14 , +DATA_TYPE_RAW_14BIT , +DECODE_FORMAT_UNCOMPRESSED_14_BIT , +14 , +1 , + }, + { +MEDIA_BUS_FMT_SGBRG14_1X14 , +DATA_TYPE_RAW_14BIT , +DECODE_FORMAT_UNCOMPRESSED_14_BIT , +14 , +1 , + }, + { +MEDIA_BUS_FMT_SGRBG14_1X14 , +DATA_TYPE_RAW_14BIT , +DECODE_FORMAT_UNCOMPRESSED_14_BIT , +14 , +1 , + }, + { +MEDIA_BUS_FMT_SRGGB14_1X14 , +DATA_TYPE_RAW_14BIT , +DECODE_FORMAT_UNCOMPRESSED_14_BIT , +14 , +1 , + }, + { +MEDIA_BUS_FMT_Y10_1X10 , +DATA_TYPE_RAW_10BIT , +DECODE_FORMAT_UNCOMPRESSED_10_BIT , +10 , +1 , + }, +}; + +static void csid_configure_stream (struct csid_device *csid,u8 enable) +{ +struct csid_testgen_config *tg = &csid->testgen; +u32 sink_code = csid->fmt[MSM_CSID_PAD_SINK ].code; +u32 src_code = csid->fmt[MSM_CSID_PAD_SRC ].code; +u32 val; + +if (enable) { +struct v4l2_mbus_framefmt *input_format; +const struct csid_format *format; +u8 vc =0 ;/* Virtual Channel 0 */ +u8 cid = vc *4 ;/* id of Virtual Channel and Data Type set */ +u8 dt_shift; + +if (tg->enabled) { +/* Config Test Generator */ +u32 num_bytes_per_line, num_lines; + + input_format = &csid->fmt[MSM_CSID_PAD_SRC ]; + format =csid_get_fmt_entry (csid->formats, csid->nformats, + input_format->code); + num_bytes_per_line = input_format->width * format->bpp * format->spp /8 ; + num_lines = input_format->height; + +/* 31:24 V blank, 23:13 H blank, 3:2 num of active DT */ +/* 1:0 VC */ + val = ((CAMSS_CSID_TG_VC_CFG_V_BLANKING &0xff ) <<24 ) | + ((CAMSS_CSID_TG_VC_CFG_H_BLANKING &0x7ff ) <<13 ); +writel_relaxed (val, csid->base +CAMSS_CSID_TG_VC_CFG ); + +/* 28:16 bytes per lines, 12:0 num of lines */ + val = ((num_bytes_per_line &0x1fff ) <<16 ) | + (num_lines &0x1fff ); +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_0 (0 )); + +/* 5:0 data type */ + val = format->data_type; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_1 (0 )); + +/* 2:0 output test pattern */ + val = tg->mode; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_DT_n_CGG_2 (0 )); + }else { +struct csid_phy_config *phy = &csid->phy; + + input_format = &csid->fmt[MSM_CSID_PAD_SINK ]; + format =csid_get_fmt_entry (csid->formats, csid->nformats, + input_format->code); + + val = phy->lane_cnt -1 ; + val |= phy->lane_assign <<4 ; + +writel_relaxed (val, csid->base +CAMSS_CSID_CORE_CTRL_0 ); + + val = phy->csiphy_id <<17 ; + val |=0x9 ; + +writel_relaxed (val, csid->base +CAMSS_CSID_CORE_CTRL_1 ); + } + +/* Config LUT */ + + dt_shift = (cid %4 ) *8 ; + + val =readl_relaxed (csid->base +CAMSS_CSID_CID_LUT_VC_n (vc)); + val &= ~(0xff << dt_shift); + val |= format->data_type << dt_shift; +writel_relaxed (val, csid->base +CAMSS_CSID_CID_LUT_VC_n (vc)); + + val = CAMSS_CSID_CID_n_CFG_ISPIF_EN; + val |= CAMSS_CSID_CID_n_CFG_RDI_EN; + val |= format->decode_format << CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT; + val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP; + +if ((sink_code ==MEDIA_BUS_FMT_SBGGR10_1X10 && + src_code ==MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE ) || + (sink_code ==MEDIA_BUS_FMT_Y10_1X10 && + src_code ==MEDIA_BUS_FMT_Y10_2X8_PADHI_LE )) { + val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING; + val |= CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16; + val |= CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB; + } + +writel_relaxed (val, csid->base +CAMSS_CSID_CID_n_CFG (cid)); + +if (tg->enabled) { + val =CAMSS_CSID_TG_CTRL_ENABLE ; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_CTRL ); + } + }else { +if (tg->enabled) { + val =CAMSS_CSID_TG_CTRL_DISABLE ; +writel_relaxed (val, csid->base +CAMSS_CSID_TG_CTRL ); + } + } +} + +static int csid_configure_testgen_pattern (struct csid_device *csid,s32 val) +{ +s32 regval = val -1 ; + +if (regval >0 || regval <=CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_7 ) + csid->testgen.mode = regval; + +return 0 ; +} + +static u32 csid_hw_version (struct csid_device *csid) +{ +u32 hw_version =readl_relaxed (csid->base +CAMSS_CSID_HW_VERSION ); + +dev_dbg (csid->camss->dev,"CSID HW Version = 0x%08x\n" , hw_version); + +return hw_version; +} + +/* +* isr - CSID module interrupt service routine +* @irq: Interrupt line +* @dev: CSID device +* +* Return IRQ_HANDLED on success +*/ +static irqreturn_t csid_isr (int irq,void *dev) +{ +struct csid_device *csid = dev; +u32 value; + + value =readl_relaxed (csid->base +CAMSS_CSID_IRQ_STATUS ); +writel_relaxed (value, csid->base +CAMSS_CSID_IRQ_CLEAR_CMD ); + +if ((value >>11 ) &0x1 ) +complete (&csid->reset_complete); + +return IRQ_HANDLED ; +} + +/* +* csid_reset - Trigger reset on CSID module and wait to complete +* @csid: CSID device +* +* Return 0 on success or a negative error code otherwise +*/ +static int csid_reset (struct csid_device *csid) +{ +unsigned long time; + +reinit_completion (&csid->reset_complete); + +writel_relaxed (0x7fff , csid->base +CAMSS_CSID_RST_CMD ); + + time =wait_for_completion_timeout (&csid->reset_complete, +msecs_to_jiffies (CSID_RESET_TIMEOUT_MS )); +if (!time) { +dev_err (csid->camss->dev,"CSID reset timeout\n" ); +return -EIO ; + } + +return 0 ; +} + +static u32 csid_src_pad_code (struct csid_device *csid,u32 sink_code, +unsigned int match_format_idx,u32 match_code) +{ +switch (sink_code) { +case MEDIA_BUS_FMT_SBGGR10_1X10 : + { +u32 src_code[] = { +MEDIA_BUS_FMT_SBGGR10_1X10 , +MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE , + }; + +return csid_find_code (src_code,ARRAY_SIZE (src_code), + match_format_idx, match_code); + } +case MEDIA_BUS_FMT_Y10_1X10 : + { +u32 src_code[] = { +MEDIA_BUS_FMT_Y10_1X10 , +MEDIA_BUS_FMT_Y10_2X8_PADHI_LE , + }; + +return csid_find_code (src_code,ARRAY_SIZE (src_code), + match_format_idx, match_code); + } +default : +if (match_format_idx >0 ) +return 0 ; + +return sink_code; + } +} + +static void csid_subdev_init (struct csid_device *csid) +{ + csid->formats = csid_formats; + csid->nformats =ARRAY_SIZE (csid_formats); + csid->testgen.modes = csid_testgen_modes; + csid->testgen.nmodes =CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_7 ; +} + +const struct csid_hw_ops csid_ops_4_7 = { + .configure_stream = csid_configure_stream, + .configure_testgen_pattern = csid_configure_testgen_pattern, + .hw_version = csid_hw_version, + .isr = csid_isr, + .reset = csid_reset, + .src_pad_code = csid_src_pad_code, + .subdev_init = csid_subdev_init, +};drivers/media/platform/qcom/camss/camss-csid.c +28
-588@@ -26,405 +26,35 @@#define MSM_CSID_NAME "msm_csid" -#define CAMSS_CSID_HW_VERSION 0x0 -#define CAMSS_CSID_CORE_CTRL_0 0x004 -#define CAMSS_CSID_CORE_CTRL_1 0x008 -#define CAMSS_CSID_RST_CMD (v) ((v) == CAMSS_8x16 ? 0x00c : 0x010) -#define CAMSS_CSID_CID_LUT_VC_n (v, n) \ - (((v) == CAMSS_8x16 ? 0x010 : 0x014) + 0x4 * (n)) -#define CAMSS_CSID_CID_n_CFG (v, n) \ - (((v) == CAMSS_8x16 ? 0x020 : 0x024) + 0x4 * (n)) -#define CAMSS_CSID_CID_n_CFG_ISPIF_EN BIT(0) -#define CAMSS_CSID_CID_n_CFG_RDI_EN BIT(1) -#define CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT 4 -#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_8 (0 << 8) -#define CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16 (1 << 8) -#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB (0 << 9) -#define CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_MSB (1 << 9) -#define CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP (0 << 10) -#define CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING (1 << 10) -#define CAMSS_CSID_IRQ_CLEAR_CMD (v) ((v) == CAMSS_8x16 ? 0x060 : 0x064) -#define CAMSS_CSID_IRQ_MASK (v) ((v) == CAMSS_8x16 ? 0x064 : 0x068) -#define CAMSS_CSID_IRQ_STATUS (v) ((v) == CAMSS_8x16 ? 0x068 : 0x06c) -#define CAMSS_CSID_TG_CTRL (v) ((v) == CAMSS_8x16 ? 0x0a0 : 0x0a8) -#define CAMSS_CSID_TG_CTRL_DISABLE 0xa06436 -#define CAMSS_CSID_TG_CTRL_ENABLE 0xa06437 -#define CAMSS_CSID_TG_VC_CFG (v) ((v) == CAMSS_8x16 ? 0x0a4 : 0x0ac) -#define CAMSS_CSID_TG_VC_CFG_H_BLANKING 0x3ff -#define CAMSS_CSID_TG_VC_CFG_V_BLANKING 0x7f -#define CAMSS_CSID_TG_DT_n_CGG_0 (v, n) \ - (((v) == CAMSS_8x16 ? 0x0ac : 0x0b4) + 0xc * (n)) -#define CAMSS_CSID_TG_DT_n_CGG_1 (v, n) \ - (((v) == CAMSS_8x16 ? 0x0b0 : 0x0b8) + 0xc * (n)) -#define CAMSS_CSID_TG_DT_n_CGG_2 (v, n) \ - (((v) == CAMSS_8x16 ? 0x0b4 : 0x0bc) + 0xc * (n)) - -#define DATA_TYPE_EMBEDDED_DATA_8BIT 0x12 -#define DATA_TYPE_YUV422_8BIT 0x1e -#define DATA_TYPE_RAW_6BIT 0x28 -#define DATA_TYPE_RAW_8BIT 0x2a -#define DATA_TYPE_RAW_10BIT 0x2b -#define DATA_TYPE_RAW_12BIT 0x2c -#define DATA_TYPE_RAW_14BIT 0x2d - -#define DECODE_FORMAT_UNCOMPRESSED_6_BIT 0x0 -#define DECODE_FORMAT_UNCOMPRESSED_8_BIT 0x1 -#define DECODE_FORMAT_UNCOMPRESSED_10_BIT 0x2 -#define DECODE_FORMAT_UNCOMPRESSED_12_BIT 0x3 -#define DECODE_FORMAT_UNCOMPRESSED_14_BIT 0x8 - -#define CSID_RESET_TIMEOUT_MS 500 - -struct csid_format { -u32 code; -u8 data_type; -u8 decode_format; -u8 bpp; -u8 spp;/* bus samples per pixel */ -}; - -static const struct csid_format csid_formats_8x16[] = { - { -MEDIA_BUS_FMT_UYVY8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_VYUY8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_YUYV8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_YVYU8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_SBGGR8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_Y10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, -}; - -static const struct csid_format csid_formats_8x96[] = { - { -MEDIA_BUS_FMT_UYVY8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_VYUY8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_YUYV8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_YVYU8_2X8 , -DATA_TYPE_YUV422_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -2 , - }, - { -MEDIA_BUS_FMT_SBGGR8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB8_1X8 , -DATA_TYPE_RAW_8BIT , -DECODE_FORMAT_UNCOMPRESSED_8_BIT , -8 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB12_1X12 , -DATA_TYPE_RAW_12BIT , -DECODE_FORMAT_UNCOMPRESSED_12_BIT , -12 , -1 , - }, - { -MEDIA_BUS_FMT_SBGGR14_1X14 , -DATA_TYPE_RAW_14BIT , -DECODE_FORMAT_UNCOMPRESSED_14_BIT , -14 , -1 , - }, - { -MEDIA_BUS_FMT_SGBRG14_1X14 , -DATA_TYPE_RAW_14BIT , -DECODE_FORMAT_UNCOMPRESSED_14_BIT , -14 , -1 , - }, - { -MEDIA_BUS_FMT_SGRBG14_1X14 , -DATA_TYPE_RAW_14BIT , -DECODE_FORMAT_UNCOMPRESSED_14_BIT , -14 , -1 , - }, - { -MEDIA_BUS_FMT_SRGGB14_1X14 , -DATA_TYPE_RAW_14BIT , -DECODE_FORMAT_UNCOMPRESSED_14_BIT , -14 , -1 , - }, - { -MEDIA_BUS_FMT_Y10_1X10 , -DATA_TYPE_RAW_10BIT , -DECODE_FORMAT_UNCOMPRESSED_10_BIT , -10 , -1 , - }, -}; -static u32 csid_find_code (u32 *code,unsigned int n_code, -unsigned int index,u32 req_code) +u32 csid_find_code (u32 *codes,unsigned int ncodes, +unsigned int match_format_idx,u32 match_code) {int i; -if (!req_code && (index >= n_code)) +if (!match_code && (match_format_idx >= ncodes))return 0 ; -for (i =0 ; i < n_code; i++) -if (req_code) { -if (req_code == code[i]) -return req_code; +for (i =0 ; i < ncodes; i++) +if (match_code) { +if (codes[i] == match_code) +return match_code; }else { -if (i == index) -return code[i]; - } - -return code[0 ]; -} - -static u32 csid_src_pad_code (struct csid_device *csid,u32 sink_code, -unsigned int index,u32 src_req_code) -{ -if (csid->camss->version == CAMSS_8x16) { -if (index >0 ) -return 0 ; - -return sink_code; - }else if (csid->camss->version == CAMSS_8x96 || - csid->camss->version ==CAMSS_660 ) { -switch (sink_code) { -case MEDIA_BUS_FMT_SBGGR10_1X10 : - { -u32 src_code[] = { -MEDIA_BUS_FMT_SBGGR10_1X10 , -MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE , - }; - -return csid_find_code (src_code,ARRAY_SIZE (src_code), - index, src_req_code); - } -case MEDIA_BUS_FMT_Y10_1X10 : - { -u32 src_code[] = { -MEDIA_BUS_FMT_Y10_1X10 , -MEDIA_BUS_FMT_Y10_2X8_PADHI_LE , - }; - -return csid_find_code (src_code,ARRAY_SIZE (src_code), - index, src_req_code); +if (i == match_format_idx) +return codes[i]; } -default : -if (index >0 ) -return 0 ; -return sink_code; - } - }else { -return 0 ; - } +return codes[0 ]; } -static const struct csid_format *csid_get_fmt_entry ( +const struct csid_format *csid_get_fmt_entry (const struct csid_format *formats, -unsigned int nformat, +unsigned int nformats,u32 code) {unsigned int i; -for (i =0 ; i < nformat; i++) +for (i =0 ; i < nformats; i++)if (code == formats[i].code)return &formats[i];@@ -433,28 +63,6 @@ static const struct csid_format *csid_get_fmt_entry(return &formats[0 ]; } -/* -* csid_isr - CSID module interrupt handler -* @irq: Interrupt line -* @dev: CSID device -* -* Return IRQ_HANDLED on success -*/ -static irqreturn_t csid_isr (int irq,void *dev) -{ -struct csid_device *csid = dev; -enum camss_version ver = csid->camss->version; -u32 value; - - value =readl_relaxed (csid->base +CAMSS_CSID_IRQ_STATUS (ver)); -writel_relaxed (value, csid->base +CAMSS_CSID_IRQ_CLEAR_CMD (ver)); - -if ((value >>11 ) &0x1 ) -complete (&csid->reset_complete); - -return IRQ_HANDLED ; -} -/* * csid_set_clock_rates - Calculate and set clock rates on CSID module * @csiphy: CSID device @@ -521,31 +129,6 @@ static int csid_set_clock_rates(struct csid_device *csid)return 0 ; } -/* -* csid_reset - Trigger reset on CSID module and wait to complete -* @csid: CSID device -* -* Return 0 on success or a negative error code otherwise -*/ -static int csid_reset (struct csid_device *csid) -{ -unsigned long time; - -reinit_completion (&csid->reset_complete); - -writel_relaxed (0x7fff , csid->base + -CAMSS_CSID_RST_CMD (csid->camss->version)); - - time =wait_for_completion_timeout (&csid->reset_complete, -msecs_to_jiffies (CSID_RESET_TIMEOUT_MS )); -if (!time) { -dev_err (csid->camss->dev,"CSID reset timeout\n" ); -return -EIO ; - } - -return 0 ; -} -/* * csid_set_power - Power on/off CSID module * @sd: CSID V4L2 subdevice @@ -560,8 +143,6 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)int ret;if (on) { -u32 hw_version; - ret =pm_runtime_get_sync (dev);if (ret <0 ) {pm_runtime_put_sync (dev);@@ -590,7 +171,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)enable_irq (csid->irq); - ret =csid_reset (csid); + ret = csid->ops->reset (csid);if (ret <0 ) {disable_irq (csid->irq);camss_disable_clocks (csid->nclocks, csid->clock);@@ -599,8 +180,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)return ret; } - hw_version =readl_relaxed (csid->base +CAMSS_CSID_HW_VERSION ); -dev_dbg (dev,"CSID HW Version = 0x%08x\n" , hw_version); + csid->ops->hw_version (csid); }else {disable_irq (csid->irq);camss_disable_clocks (csid->nclocks, csid->clock);@@ -623,16 +203,9 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)static int csid_set_stream (struct v4l2_subdev *sd,int enable) {struct csid_device *csid =v4l2_get_subdevdata (sd); -struct csid_testgen_config *tg = &csid->testgen; -enum camss_version ver = csid->camss->version; -u32 val; +int ret;if (enable) { -u8 vc =0 ;/* Virtual Channel 0 */ -u8 cid = vc *4 ;/* id of Virtual Channel and Data Type set */ -u8 dt, dt_shift, df; -int ret; - ret =v4l2_ctrl_handler_setup (&csid->ctrls);if (ret <0 ) { dev_err(csid->camss->dev,@@ -640,116 +213,13 @@ static int csid_set_stream(struct v4l2_subdev *sd, int enable)return ret; } -if (!tg->enabled && +if (!csid->testgen.enabled && !media_entity_remote_pad (&csid->pads[MSM_CSID_PAD_SINK ]))return -ENOLINK ; - -if (tg->enabled) { -/* Config Test Generator */ -struct v4l2_mbus_framefmt *f = - &csid->fmt[MSM_CSID_PAD_SRC ]; -const struct csid_format *format =csid_get_fmt_entry ( - csid->formats, csid->nformats, f->code); -u32 num_bytes_per_line = - f->width * format->bpp * format->spp /8 ; -u32 num_lines = f->height; - -/* 31:24 V blank, 23:13 H blank, 3:2 num of active DT */ -/* 1:0 VC */ - val = ((CAMSS_CSID_TG_VC_CFG_V_BLANKING &0xff ) <<24 ) | - ((CAMSS_CSID_TG_VC_CFG_H_BLANKING &0x7ff ) <<13 ); -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_VC_CFG (ver)); - -/* 28:16 bytes per lines, 12:0 num of lines */ - val = ((num_bytes_per_line &0x1fff ) <<16 ) | - (num_lines &0x1fff ); -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_DT_n_CGG_0 (ver,0 )); - - dt = format->data_type; - -/* 5:0 data type */ - val = dt; -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_DT_n_CGG_1 (ver,0 )); - -/* 2:0 output test pattern */ - val = tg->payload_mode; -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_DT_n_CGG_2 (ver,0 )); - - df = format->decode_format; - }else { -struct v4l2_mbus_framefmt *f = - &csid->fmt[MSM_CSID_PAD_SINK ]; -const struct csid_format *format =csid_get_fmt_entry ( - csid->formats, csid->nformats, f->code); -struct csid_phy_config *phy = &csid->phy; - - val = phy->lane_cnt -1 ; - val |= phy->lane_assign <<4 ; - -writel_relaxed (val, - csid->base +CAMSS_CSID_CORE_CTRL_0 ); - - val = phy->csiphy_id <<17 ; - val |=0x9 ; - -writel_relaxed (val, - csid->base +CAMSS_CSID_CORE_CTRL_1 ); - - dt = format->data_type; - df = format->decode_format; - } - -/* Config LUT */ - - dt_shift = (cid %4 ) *8 ; - - val =readl_relaxed (csid->base + -CAMSS_CSID_CID_LUT_VC_n (ver, vc)); - val &= ~(0xff << dt_shift); - val |= dt << dt_shift; -writel_relaxed (val, csid->base + -CAMSS_CSID_CID_LUT_VC_n (ver, vc)); - - val = CAMSS_CSID_CID_n_CFG_ISPIF_EN; - val |= CAMSS_CSID_CID_n_CFG_RDI_EN; - val |= df << CAMSS_CSID_CID_n_CFG_DECODE_FORMAT_SHIFT; - val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_RAW_DUMP; - -if (csid->camss->version == CAMSS_8x96 || - csid->camss->version ==CAMSS_660 ) { -u32 sink_code = csid->fmt[MSM_CSID_PAD_SINK ].code; -u32 src_code = csid->fmt[MSM_CSID_PAD_SRC ].code; - -if ((sink_code ==MEDIA_BUS_FMT_SBGGR10_1X10 && - src_code ==MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE ) || - (sink_code ==MEDIA_BUS_FMT_Y10_1X10 && - src_code ==MEDIA_BUS_FMT_Y10_2X8_PADHI_LE )) { - val |= CAMSS_CSID_CID_n_CFG_RDI_MODE_PLAIN_PACKING; - val |= CAMSS_CSID_CID_n_CFG_PLAIN_FORMAT_16; - val |= CAMSS_CSID_CID_n_CFG_PLAIN_ALIGNMENT_LSB; - } - } - -writel_relaxed (val, csid->base + -CAMSS_CSID_CID_n_CFG (ver, cid)); - -if (tg->enabled) { - val =CAMSS_CSID_TG_CTRL_ENABLE ; -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_CTRL (ver)); - } - }else { -if (tg->enabled) { - val =CAMSS_CSID_TG_CTRL_DISABLE ; -writel_relaxed (val, csid->base + -CAMSS_CSID_TG_CTRL (ver)); - } } + csid->ops->configure_stream (csid, enable); +return 0 ; }@@ -818,7 +288,7 @@ static void csid_try_format(struct csid_device *csid, *fmt = *__csid_get_format (csid, cfg,MSM_CSID_PAD_SINK , which); - fmt->code =csid_src_pad_code (csid, fmt->code,0 , code); + fmt->code = csid->ops->src_pad_code (csid, fmt->code,0 , code); }else {/* Test generator is enabled, set format on source */ /* pad to allow test generator usage */ @@ -868,7 +338,7 @@ static int csid_enum_mbus_code(struct v4l2_subdev *sd,MSM_CSID_PAD_SINK , code->which); - code->code =csid_src_pad_code (csid, sink_fmt->code, + code->code = csid->ops->src_pad_code (csid, sink_fmt->code, code->index,0 );if (!code->code)return -EINVAL ;@@ -1004,15 +474,6 @@ static int csid_init_formats(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)return csid_set_format (sd, fh ? fh->pad :NULL , &format); } -static const char *const csid_test_pattern_menu[] = { -"Disabled" , -"Incrementing" , -"Alternating 0x55/0xAA" , -"All Zeros 0x00" , -"All Ones 0xFF" , -"Pseudo-random Data" , -}; -/* * csid_set_test_pattern - Set test generator's pattern mode * @csid: CSID device @@ -1030,25 +491,7 @@ static int csid_set_test_pattern(struct csid_device *csid, s32 value) tg->enabled = !!value; -switch (value) { -case 1 : - tg->payload_mode =CSID_PAYLOAD_MODE_INCREMENTING ; -break ; -case 2 : - tg->payload_mode =CSID_PAYLOAD_MODE_ALTERNATING_55_AA ; -break ; -case 3 : - tg->payload_mode =CSID_PAYLOAD_MODE_ALL_ZEROES ; -break ; -case 4 : - tg->payload_mode =CSID_PAYLOAD_MODE_ALL_ONES ; -break ; -case 5 : - tg->payload_mode =CSID_PAYLOAD_MODE_RANDOM ; -break ; - } - -return 0 ; +return csid->ops->configure_testgen_pattern (csid, value); }/* @@ -1097,17 +540,14 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, csid->id = id;if (camss->version == CAMSS_8x16) { - csid->formats = csid_formats_8x16; - csid->nformats = -ARRAY_SIZE (csid_formats_8x16); + csid->ops = &csid_ops_4_1; }else if (camss->version == CAMSS_8x96 || camss->version ==CAMSS_660 ) { - csid->formats = csid_formats_8x96; - csid->nformats = -ARRAY_SIZE (csid_formats_8x96); + csid->ops = &csid_ops_4_7; }else {return -EINVAL ; } + csid->ops->subdev_init (csid);/* Memory */ @@ -1130,7 +570,7 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, csid->irq = r->start;snprintf (csid->irq_name,sizeof (csid->irq_name),"%s_%s%d" ,dev_name (dev),MSM_CSID_NAME , csid->id); - ret =devm_request_irq (dev, csid->irq, csid_isr, + ret =devm_request_irq (dev, csid->irq, csid->ops->isr,IRQF_TRIGGER_RISING , csid->irq_name, csid);if (ret <0 ) {dev_err (dev,"request_irq failed: %d\n" , ret);@@ -1341,8 +781,8 @@ int msm_csid_register_entity(struct csid_device *csid, csid->testgen_mode =v4l2_ctrl_new_std_menu_items (&csid->ctrls, &csid_ctrl_ops,V4L2_CID_TEST_PATTERN , -ARRAY_SIZE (csid_test_pattern_menu) -1 ,0 ,0 , - csid_test_pattern_menu); + csid->testgen.nmodes,0 ,0 , + csid->testgen.modes);if (csid->ctrls.error) {dev_err (dev,"Failed to init ctrl: %d\n" , csid->ctrls.error);drivers/media/platform/qcom/camss/camss-csid.h +124
-2@@ -11,6 +11,7 @@#define QC_MSM_CAMSS_CSID_H #include <linux/clk.h> +#include <linux/interrupt.h> #include <media/media-entity.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-device.h> @@ -70,19 +71,50 @@#define PLAIN_FORMAT_PLAIN16 0x1/* supports DPCM, UNCOMPRESSED_10/16_BIT */ #define PLAIN_FORMAT_PLAIN32 0x2/* supports UNCOMPRESSED_20_BIT */ +#define CSID_RESET_TIMEOUT_MS 500 -enum csid_payload_mode { + +enum csid_testgen_mode {CSID_PAYLOAD_MODE_INCREMENTING =0 ,CSID_PAYLOAD_MODE_ALTERNATING_55_AA =1 ,CSID_PAYLOAD_MODE_ALL_ZEROES =2 ,CSID_PAYLOAD_MODE_ALL_ONES =3 ,CSID_PAYLOAD_MODE_RANDOM =4 ,CSID_PAYLOAD_MODE_USER_SPECIFIED =5 , +CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_1 =5 , +CSID_PAYLOAD_MODE_MAX_SUPPORTED_4_7 =5 , +CSID_PAYLOAD_MODE_COMPLEX_PATTERN =6 , +CSID_PAYLOAD_MODE_COLOR_BOX =7 , +CSID_PAYLOAD_MODE_COLOR_BARS =8 , +CSID_PAYLOAD_MODE_MAX_SUPPORTED_170 =8 , +}; + +static const char *const csid_testgen_modes[] = { +"Disabled" , +"Incrementing" , +"Alternating 0x55/0xAA" , +"All Zeros 0x00" , +"All Ones 0xFF" , +"Pseudo-random Data" , +"User Specified" , +"Complex pattern" , +"Color box" , +"Color bars" , +}; + +struct csid_format { +u32 code; +u8 data_type; +u8 decode_format; +u8 bpp; +u8 spp;/* bus samples per pixel */ };struct csid_testgen_config { +enum csid_testgen_mode mode; +const char *const *modes; +u8 nmodes;u8 enabled; -enum csid_payload_mode payload_mode; };struct csid_phy_config {@@ -91,6 +123,65 @@ struct csid_phy_config {u32 lane_assign; }; +struct csid_device ; + +struct csid_hw_ops { +/* +* configure_stream - Configures and starts CSID input stream +* @csid: CSID device +*/ +void (*configure_stream)(struct csid_device *csid,u8 enable); + +/* +* configure_testgen_pattern - Validates and configures output pattern mode +* of test pattern generator +* @csid: CSID device +*/ +int (*configure_testgen_pattern)(struct csid_device *csid,s32 val); + +/* +* hw_version - Read hardware version register from hardware +* @csid: CSID device +*/ +u32 (*hw_version)(struct csid_device *csid); + +/* +* isr - CSID module interrupt service routine +* @irq: Interrupt line +* @dev: CSID device +* +* Return IRQ_HANDLED on success +*/ +irqreturn_t (*isr)(int irq,void *dev); + +/* +* reset - Trigger reset on CSID module and wait to complete +* @csid: CSID device +* +* Return 0 on success or a negative error code otherwise +*/ +int (*reset)(struct csid_device *csid); + +/* +* src_pad_code - Pick an output/src format based on the input/sink format +* @csid: CSID device +* @sink_code: The sink format of the input +* @match_format_idx: Request preferred index, as defined by subdevice csid_format. +* Set @match_code to 0 if used. +* @match_code: Request preferred code, set @match_format_idx to 0 if used +* +* Return 0 on failure or src format code otherwise +*/ +u32 (*src_pad_code)(struct csid_device *csid,u32 sink_code, +unsigned int match_format_idx,u32 match_code); + +/* +* subdev_init - Initialize CSID device according for hardware revision +* @csid: CSID device +*/ +void (*subdev_init)(struct csid_device *csid); +}; +struct csid_device {struct camss *camss;u8 id;@@ -110,10 +201,37 @@ struct csid_device {struct v4l2_ctrl *testgen_mode;const struct csid_format *formats;unsigned int nformats; +const struct csid_hw_ops *ops; };struct resources ; + +/* +* csid_find_code - Find a format code in an array using array index or format code +* @codes: Array of format codes +* @ncodes: Length of @code array +* @req_format_idx: Request preferred index, as defined by subdevice csid_format. +* Set @match_code to 0 if used. +* @match_code: Request preferred code, set @req_format_idx to 0 if used +* +* Return 0 on failure or format code otherwise +*/ +u32 csid_find_code (u32 *codes,unsigned int ncode, +unsigned int match_format_idx,u32 match_code); + +/* +* csid_get_fmt_entry - Find csid_format entry with matching format code +* @formats: Array of format csid_format entries +* @nformats: Length of @nformats array +* @code: Desired format code +* +* Return formats[0] on failure to find code +*/ +const struct csid_format *csid_get_fmt_entry (const struct csid_format *formats, +unsigned int nformats, +u32 code); +int msm_csid_subdev_init (struct camss *camss,struct csid_device *csid,const struct resources *res,u8 id);@@ -124,4 +242,8 @@ void msm_csid_unregister_entity(struct csid_device *csid);void msm_csid_get_csid_id (struct media_entity *entity,u8 *id); + +extern const struct csid_hw_ops csid_ops_4_1; +extern const struct csid_hw_ops csid_ops_4_7; +#endif /* QC_MSM_CAMSS_CSID_H */
PATCH v4 10/22 media: camss: Add support for CSID hardware version Titan 170
In reply to Robert FossAdd register definitions for version 170 of the Titan architecture and implement support for the CSID subdevice.
---
Changes since v3
- Sakari: Make variable const
drivers/media/platform/qcom/camss/Makefile | 1 + .../platform/qcom/camss/camss-csid-170.c | 602 ++++++++++++++++++ .../media/platform/qcom/camss/camss-csid.c | 4 + .../media/platform/qcom/camss/camss-csid.h | 2 + .../media/platform/qcom/camss/camss-vfe-170.c | 1 - drivers/media/platform/qcom/camss/camss.c | 62 ++ 6 files changed, 671 insertions(+), 1 deletion(-) create mode 100644 drivers/media/platform/qcom/camss/camss-csid-170.c
drivers/media/platform/qcom/camss/Makefile +1 -0
@@ -6,6 +6,7 @@ qcom-camss-objs += \ camss-csid.o \ camss-csid-4-1.o \ camss-csid-4-7.o \ + camss-csid-170.o \ camss-csiphy-2ph-1-0.o \ camss-csiphy-3ph-1-0.o \ camss-csiphy.o \
drivers/media/platform/qcom/camss/camss-csid-170.c new file +602 -0
602 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss-csid.c +4 -0
@@ -123,6 +123,8 @@ static int csid_set_clock_rates(struct csid_device *csid)dev_err (dev,"clk set rate failed: %d\n" , ret);return ret; } + }else if (clock->nfreqs) { +clk_set_rate (clock->clk, clock->freq[0 ]); } }
@@ -544,6 +546,8 @@ int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid, }else if (camss->version == CAMSS_8x96 || camss->version ==CAMSS_660 ) { csid->ops = &csid_ops_4_7; + }else if (camss->version ==CAMSS_845 ) { + csid->ops = &csid_ops_170; }else {return -EINVAL ; }
drivers/media/platform/qcom/camss/camss-csid.h +2 -0
@@ -245,5 +245,7 @@ void msm_csid_get_csid_id(struct media_entity *entity, u8 *id);extern const struct csid_hw_ops csid_ops_4_1;extern const struct csid_hw_ops csid_ops_4_7; +extern const struct csid_hw_ops csid_ops_170; +#endif /* QC_MSM_CAMSS_CSID_H */
drivers/media/platform/qcom/camss/camss-vfe-170.c +0 -1
@@ -277,7 +277,6 @@ static void vfe_wm_start(struct vfe_device *vfe, u8 wm, struct vfe_line *line)writel_relaxed (val, vfe->base +VFE_BUS_WM_PACKER_CFG (wm));// XXX 1 for PLAIN8? /* Configure stride for RDIs */ -//val = pix->plane_fmt[0].bytesperline; val =WM_STRIDE_DEFAULT_STRIDE ;writel_relaxed (val, vfe->base +VFE_BUS_WM_STRIDE (wm));
drivers/media/platform/qcom/camss/camss.c +62 -0
68 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v4 11/22 media: camss: Add support for CSIPHY hardware version Titan 170
In reply to Robert FossAdd register definitions for version 170 of the Titan architecture and implement support for the CSIPHY subdevice.
--- .../qcom/camss/camss-csiphy-3ph-1-0.c | 182 ++++++++++++++++-- .../media/platform/qcom/camss/camss-csiphy.c | 66 +++++-- drivers/media/platform/qcom/camss/camss.c | 74 +++++++ 3 files changed, 290 insertions(+), 32 deletions(-)
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +164 -18
@@ -47,6 +47,105 @@#define CSIPHY_3PH_CMN_CSI_COMMON_CTRL6_SHOW_REV_ID BIT(1)#define CSIPHY_3PH_CMN_CSI_COMMON_STATUSn (n) (0x8b0 + 0x4 * (n)) +#define CSIPHY_DEFAULT_PARAMS 0 +#define CSIPHY_LANE_ENABLE 1 +#define CSIPHY_SETTLE_CNT_LOWER_BYTE 2 +#define CSIPHY_SETTLE_CNT_HIGHER_BYTE 3 +#define CSIPHY_DNP_PARAMS 4 +#define CSIPHY_2PH_REGS 5 +#define CSIPHY_3PH_REGS 6 + +struct csiphy_reg_t { +int32_t reg_addr; +int32_t reg_data; +int32_t delay; +uint32_t csiphy_param_type; +}; + +static const struct +csiphy_reg_t lane_regs_sdm845[5 ][14 ] = { + { + {0x0004 ,0x0C ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x002C ,0x01 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0034 ,0x0F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x001C ,0x0A ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0014 ,0x60 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0028 ,0x00 ,0x00 ,CSIPHY_DNP_PARAMS }, + {0x003C ,0xB8 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0000 ,0x91 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0008 ,0x00 ,0x00 ,CSIPHY_SETTLE_CNT_LOWER_BYTE }, + {0x000c ,0x00 ,0x00 ,CSIPHY_DNP_PARAMS }, + {0x0010 ,0x52 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0038 ,0xFE ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0060 ,0x00 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0064 ,0x7F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + }, + { + {0x0704 ,0x0C ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x072C ,0x01 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0734 ,0x0F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x071C ,0x0A ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0714 ,0x60 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0728 ,0x04 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x073C ,0xB8 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0700 ,0x80 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0708 ,0x14 ,0x00 ,CSIPHY_SETTLE_CNT_LOWER_BYTE }, + {0x070C ,0xA5 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0710 ,0x52 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0738 ,0x1F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0760 ,0x00 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0764 ,0x7F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + }, + { + {0x0204 ,0x0C ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x022C ,0x01 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0234 ,0x0F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x021C ,0x0A ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0214 ,0x60 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0228 ,0x00 ,0x00 ,CSIPHY_DNP_PARAMS }, + {0x023C ,0xB8 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0200 ,0x91 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0208 ,0x00 ,0x00 ,CSIPHY_SETTLE_CNT_LOWER_BYTE }, + {0x020C ,0x00 ,0x00 ,CSIPHY_DNP_PARAMS }, + {0x0210 ,0x52 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0238 ,0xFE ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0260 ,0x00 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0264 ,0x7F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + }, + { + {0x0404 ,0x0C ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x042C ,0x01 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0434 ,0x0F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x041C ,0x0A ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0414 ,0x60 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0428 ,0x00 ,0x00 ,CSIPHY_DNP_PARAMS }, + {0x043C ,0xB8 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0400 ,0x91 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0408 ,0x00 ,0x00 ,CSIPHY_SETTLE_CNT_LOWER_BYTE }, + {0x040C ,0x00 ,0x00 ,CSIPHY_DNP_PARAMS }, + {0x0410 ,0x52 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0438 ,0xFE ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0460 ,0x00 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0464 ,0x7F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + }, + { + {0x0604 ,0x0C ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x062C ,0x01 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0634 ,0x0F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x061C ,0x0A ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0614 ,0x60 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0628 ,0x00 ,0x00 ,CSIPHY_DNP_PARAMS }, + {0x063C ,0xB8 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0600 ,0x91 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0608 ,0x00 ,0x00 ,CSIPHY_SETTLE_CNT_LOWER_BYTE }, + {0x060C ,0x00 ,0x00 ,CSIPHY_DNP_PARAMS }, + {0x0610 ,0x52 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0638 ,0xFE ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0660 ,0x00 ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + {0x0664 ,0x7F ,0x00 ,CSIPHY_DEFAULT_PARAMS }, + }, +}; +static void csiphy_hw_version_read (struct csiphy_device *csiphy,struct device *dev) {
@@ -135,26 +234,13 @@ static u8 csiphy_settle_cnt_calc(u32 pixel_clock, u8 bpp, u8 num_lanes,return settle_cnt; } -static void csiphy_lanes_enable (struct csiphy_device *csiphy, -struct csiphy_config *cfg, -u32 pixel_clock,u8 bpp,u8 lane_mask) +static void csiphy_gen1_config_lanes (struct csiphy_device *csiphy, +struct csiphy_config *cfg, +u8 settle_cnt) {struct csiphy_lanes_cfg *c = &cfg->csi2->lane_cfg; -u8 settle_cnt; -u8 val, l =0 ; -int i; - - settle_cnt =csiphy_settle_cnt_calc (pixel_clock, bpp, c->num_data, - csiphy->timer_clk_rate); - - val =BIT (c->clk.pos); -for (i =0 ; i < c->num_data; i++) - val |=BIT (c->data[i].pos *2 ); - -writel_relaxed (val, csiphy->base +CSIPHY_3PH_CMN_CSI_COMMON_CTRLn (5 )); - - val =CSIPHY_3PH_CMN_CSI_COMMON_CTRL6_COMMON_PWRDN_B ; -writel_relaxed (val, csiphy->base +CSIPHY_3PH_CMN_CSI_COMMON_CTRLn (6 )); +int i, l =0 ; +u8 val;for (i =0 ; i <= c->num_data; i++) {if (i == c->num_data)
@@ -208,6 +294,66 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy, val = CSIPHY_3PH_LNn_MISC1_IS_CLKLANE;writel_relaxed (val, csiphy->base +CSIPHY_3PH_LNn_MISC1 (l)); +} + +static void csiphy_gen2_config_lanes (struct csiphy_device *csiphy, +u8 settle_cnt) +{ +int i, l; +u32 val; + +for (l =0 ; l <5 ; l++) { +for (i =0 ; i <14 ; i++) { +struct csiphy_reg_t *r = &lane_regs_sdm845[l][i]; + +switch (r->csiphy_param_type) { +case CSIPHY_SETTLE_CNT_LOWER_BYTE : + val = settle_cnt &0xff ; +break ; +case CSIPHY_DNP_PARAMS : +continue ; +default : + val = r->reg_data; +break ; + } +writel_relaxed (val, csiphy->base + r->reg_addr); + } + } +} + +static void csiphy_lanes_enable (struct csiphy_device *csiphy, +struct csiphy_config *cfg, +u32 pixel_clock,u8 bpp,u8 lane_mask) +{ +struct csiphy_lanes_cfg *c = &cfg->csi2->lane_cfg; +u8 settle_cnt; +u8 val; +int i; + + settle_cnt =csiphy_settle_cnt_calc (pixel_clock, bpp, c->num_data, + csiphy->timer_clk_rate); + + val =BIT (c->clk.pos); +for (i =0 ; i < c->num_data; i++) + val |=BIT (c->data[i].pos *2 ); + + val =0xd5 ; +writel_relaxed (val, csiphy->base +CSIPHY_3PH_CMN_CSI_COMMON_CTRLn (5 )); + + val =1 ; +writel_relaxed (val, csiphy->base +CSIPHY_3PH_CMN_CSI_COMMON_CTRLn (6 )); + + val =0x02 ; +writel_relaxed (val, csiphy->base +CSIPHY_3PH_CMN_CSI_COMMON_CTRLn (7 )); + + val =0x00 ; +writel_relaxed (val, csiphy->base +CSIPHY_3PH_CMN_CSI_COMMON_CTRLn (0 )); + +if (csiphy->camss->version == CAMSS_8x16 || + csiphy->camss->version == CAMSS_8x96) +csiphy_gen1_config_lanes (csiphy, cfg, settle_cnt); +else if (csiphy->camss->version ==CAMSS_845 ) +csiphy_gen2_config_lanes (csiphy, settle_cnt); val =0xff ;writel_relaxed (val, csiphy->base +CSIPHY_3PH_CMN_CSI_COMMON_CTRLn (11 ));
drivers/media/platform/qcom/camss/camss-csiphy.c +52 -14
91 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss.c +74 -0
80 lines not on this page · raw message
Signature · 1 line
2.27.0
kernel test robot
build botRe: [PATCH v4 11/22] media: camss: Add support for CSIPHY hardware version Titan 170
I love your patch! Perhaps something to improve:
Hi Robert,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on robh/for-next linus/master v5.11-rc6 next-20210125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Robert-Foss/Add-support-for-the-SDM845-Camera-Subsystem/20210206-071553 base: git://linuxtv.org/media_tree.git master config: sparc-allyesconfig (attached as .config) compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/f4da8d1038a233c7c82c8fe394cfe861745e807f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Robert-Foss/Add-support-for-the-SDM845-Camera-Subsystem/20210206-071553 git checkout f4da8d1038a233c7c82c8fe394cfe861745e807f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sparc
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c: In function 'csiphy_gen2_config_lanes':
>> drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c:307:29: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
307 | struct csiphy_reg_t *r = &lane_regs_sdm845[l][i];
| ^
In file included from drivers/media/platform/qcom/camss/camss.h:21,
from drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c:11:
At top level:
drivers/media/platform/qcom/camss/camss-csid.h:92:27: warning: 'csid_testgen_modes' defined but not used [-Wunused-const-variable=]
92 | static const char * const csid_testgen_modes[] = {
| ^~~~~~~~~~~~~~~~~~vim +/const +307 drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
298
299 static void csiphy_gen2_config_lanes(struct csiphy_device *csiphy,
300 u8 settle_cnt)
301 {
302 int i, l;
303 u32 val;
304
305 for (l = 0; l < 5; l++) {
306 for (i = 0; i < 14; i++) {
> 307 struct csiphy_reg_t *r = &lane_regs_sdm845[l][i];
308
309 switch (r->csiphy_param_type) {
310 case CSIPHY_SETTLE_CNT_LOWER_BYTE:
311 val = settle_cnt & 0xff;
312 break;
313 case CSIPHY_DNP_PARAMS:
314 continue;
315 default:
316 val = r->reg_data;
317 break;
318 }
319 writel_relaxed(val, csiphy->base + r->reg_addr);
320 }
321 }
322 }
323
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH v4 11/22] media: camss: Add support for CSIPHY hardware version Titan 170
In reply to Robert FossHi Robert,
Thank you for your patchset!
Quoted 35 lines · Robert Foss
Add register definitions for version 170 of the Titan architecture and implement support for the CSIPHY subdevice.
Signed-off-by Robert Foss <[email protected]>--- .../qcom/camss/camss-csiphy-3ph-1-0.c | 182 ++++++++++++++++-- .../media/platform/qcom/camss/camss-csiphy.c | 66 +++++-- drivers/media/platform/qcom/camss/camss.c | 74 +++++++ 3 files changed, 290 insertions(+), 32 deletions(-)drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +17
-0@@ -47,6 +47,105 @@#define CSIPHY_3PH_CMN_CSI_COMMON_CTRL6_SHOW_REV_ID BIT(1)#define CSIPHY_3PH_CMN_CSI_COMMON_STATUSn (n) (0x8b0 + 0x4 * (n)) +#define CSIPHY_DEFAULT_PARAMS 0 +#define CSIPHY_LANE_ENABLE 1 +#define CSIPHY_SETTLE_CNT_LOWER_BYTE 2 +#define CSIPHY_SETTLE_CNT_HIGHER_BYTE 3 +#define CSIPHY_DNP_PARAMS 4 +#define CSIPHY_2PH_REGS 5 +#define CSIPHY_3PH_REGS 6 + +struct csiphy_reg_t { +int32_t reg_addr; +int32_t reg_data; +int32_t delay; +uint32_t csiphy_param_type; +}; + +static const struct +csiphy_reg_t lane_regs_sdm845[5 ][14 ] = {
<snip>
Quoted 5 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +1
-0@@ -208,6 +294,66 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy, val = CSIPHY_3PH_LNn_MISC1_IS_CLKLANE;writel_relaxed (val, csiphy->base +CSIPHY_3PH_LNn_MISC1 (l)); +}
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c static void csiphy_lanes_enable(struct csiphy_device *csiphy, · line 307
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +10
-0+ +static void csiphy_gen2_config_lanes (struct csiphy_device *csiphy, +u8 settle_cnt) +{ +int i, l; +u32 val; + +for (l =0 ; l <5 ; l++) { +for (i =0 ; i <14 ; i++) { +struct csiphy_reg_t *r = &lane_regs_sdm845[l][i];
- this line gives me a compilation warning :
warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
306 | struct csiphy_reg_t *r = &lane_regs_sdm845[l][i];
Change it to:
const struct csiphy_reg_t *r = &lane_regs_sdm845[l][i];
?
Thanks,
Andrey
Re: [PATCH v4 11/22] media: camss: Add support for CSIPHY hardware version Titan 170
Hey Andrey,
Quoted 64 lines · Andrey Konovalov
Hi Robert,
Thank you for your patchset!
Quoted 35 lines · Robert Foss
Add register definitions for version 170 of the Titan architecture and implement support for the CSIPHY subdevice.
Signed-off-by Robert Foss <[email protected]>--- .../qcom/camss/camss-csiphy-3ph-1-0.c | 182 ++++++++++++++++-- .../media/platform/qcom/camss/camss-csiphy.c | 66 +++++-- drivers/media/platform/qcom/camss/camss.c | 74 +++++++ 3 files changed, 290 insertions(+), 32 deletions(-)drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +17
-0@@ -47,6 +47,105 @@#define CSIPHY_3PH_CMN_CSI_COMMON_CTRL6_SHOW_REV_ID BIT(1)#define CSIPHY_3PH_CMN_CSI_COMMON_STATUSn (n) (0x8b0 + 0x4 * (n)) +#define CSIPHY_DEFAULT_PARAMS 0 +#define CSIPHY_LANE_ENABLE 1 +#define CSIPHY_SETTLE_CNT_LOWER_BYTE 2 +#define CSIPHY_SETTLE_CNT_HIGHER_BYTE 3 +#define CSIPHY_DNP_PARAMS 4 +#define CSIPHY_2PH_REGS 5 +#define CSIPHY_3PH_REGS 6 + +struct csiphy_reg_t { +int32_t reg_addr; +int32_t reg_data; +int32_t delay; +uint32_t csiphy_param_type; +}; + +static const struct +csiphy_reg_t lane_regs_sdm845[5 ][14 ] = {<snip>
Quoted 5 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +1
-0@@ -208,6 +294,66 @@ static void csiphy_lanes_enable(struct csiphy_device *csiphy, val = CSIPHY_3PH_LNn_MISC1_IS_CLKLANE;writel_relaxed (val, csiphy->base +CSIPHY_3PH_LNn_MISC1 (l)); +}drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c static void csiphy_lanes_enable(struct csiphy_device *csiphy, · line 307
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +10
-0+ +static void csiphy_gen2_config_lanes (struct csiphy_device *csiphy, +u8 settle_cnt) +{ +int i, l; +u32 val; + +for (l =0 ; l <5 ; l++) { +for (i =0 ; i <14 ; i++) { +struct csiphy_reg_t *r = &lane_regs_sdm845[l][i];- this line gives me a compilation warning :
warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
306 | structcsiphy_reg_t*r = &lane_regs_sdm845[l][i];
Quoted 4 lines
Change it to:
const struct csiphy_reg_t *r = &lane_regs_sdm845[l][i];?
Yep, I applied that change to my local tree. But didn't thank the bot for it's graceful contribution.
Rob.
kernel test robot
build botRe: [PATCH v4 11/22] media: camss: Add support for CSIPHY hardware version Titan 170
In reply to Robert FossI love your patch! Yet something to improve:
Hi Robert,
I love your patch! Yet something to improve:
[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on robh/for-next linus/master v5.11-rc7 next-20210125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Robert-Foss/Add-support-for-the-SDM845-Camera-Subsystem/20210206-071553 base: git://linuxtv.org/media_tree.git master config: mips-randconfig-r036-20210209 (attached as .config) compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project c9439ca36342fb6013187d0a69aef92736951476)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://github.com/0day-ci/linux/commit/f4da8d1038a233c7c82c8fe394cfe861745e807f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Robert-Foss/Add-support-for-the-SDM845-Camera-Subsystem/20210206-071553 git checkout f4da8d1038a233c7c82c8fe394cfe861745e807f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c:307:25: error: initializing 'struct csiphy_reg_t *' with an expression of type 'const struct csiphy_reg_t *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
struct csiphy_reg_t *r = &lane_regs_sdm845[l][i];
^ ~~~~~~~~~~~~~~~~~~~~~~~1 error generated.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SSB_EMBEDDED Depends on SSB && SSB_DRIVER_MIPS && SSB_PCICORE_HOSTMODE Selected by
- BCM47XX_SSB && BCM47XX
vim +307 drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c
298
299 static void csiphy_gen2_config_lanes(struct csiphy_device *csiphy,
300 u8 settle_cnt)
301 {
302 int i, l;
303 u32 val;
304
305 for (l = 0; l < 5; l++) {
306 for (i = 0; i < 14; i++) {
> 307 struct csiphy_reg_t *r = &lane_regs_sdm845[l][i];
308
309 switch (r->csiphy_param_type) {
310 case CSIPHY_SETTLE_CNT_LOWER_BYTE:
311 val = settle_cnt & 0xff;
312 break;
313 case CSIPHY_DNP_PARAMS:
314 continue;
315 default:
316 val = r->reg_data;
317 break;
318 }
319 writel_relaxed(val, csiphy->base + r->reg_addr);
320 }
321 }
322 }
323
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v4 12/22 media: camss: Remove per VFE power domain toggling
In reply to Robert FossFor Titan ISPs clocks fail to re-enable during vfe_get() after any vfe has been halted and its corresponding power domain power has been detached.
Since all of the clocks depend on all of the PDs, per VFE PD detaching is no option for this generation of HW.
--- .../media/platform/qcom/camss/camss-ispif.c | 11 --- drivers/media/platform/qcom/camss/camss-vfe.c | 7 -- drivers/media/platform/qcom/camss/camss.c | 94 +++++++++++-------- drivers/media/platform/qcom/camss/camss.h | 12 +-- 4 files changed, 60 insertions(+), 64 deletions(-)
drivers/media/platform/qcom/camss/camss-ispif.c +0 -11
@@ -323,14 +323,6 @@ static int ispif_reset(struct ispif_device *ispif, u8 vfe_id)struct camss *camss = ispif->camss;int ret; - ret =camss_pm_domain_on (camss,PM_DOMAIN_VFE0 ); -if (ret <0 ) -return ret; - - ret =camss_pm_domain_on (camss,PM_DOMAIN_VFE1 ); -if (ret <0 ) -return ret; - ret =camss_enable_clocks (ispif->nclocks_for_reset, ispif->clock_for_reset, camss->dev);
@@ -343,9 +335,6 @@ static int ispif_reset(struct ispif_device *ispif, u8 vfe_id)camss_disable_clocks (ispif->nclocks_for_reset, ispif->clock_for_reset); -camss_pm_domain_off (camss,PM_DOMAIN_VFE0 ); -camss_pm_domain_off (camss,PM_DOMAIN_VFE1 ); -return ret; }
drivers/media/platform/qcom/camss/camss-vfe.c +0 -7
@@ -587,10 +587,6 @@ static int vfe_get(struct vfe_device *vfe)mutex_lock (&vfe->power_lock);if (vfe->power_count ==0 ) { - ret =camss_pm_domain_on (vfe->camss, vfe->id); -if (ret <0 ) - goto error_pm_domain; - ret =pm_runtime_get_sync (vfe->camss->dev);if (ret <0 ) goto error_pm_runtime_get;
@@ -627,9 +623,7 @@ static int vfe_get(struct vfe_device *vfe) error_pm_runtime_get:pm_runtime_put_sync (vfe->camss->dev); -camss_pm_domain_off (vfe->camss, vfe->id); -error_pm_domain:mutex_unlock (&vfe->power_lock);return ret;
@@ -653,7 +647,6 @@ static void vfe_put(struct vfe_device *vfe) }camss_disable_clocks (vfe->nclocks, vfe->clock);pm_runtime_put_sync (vfe->camss->dev); -camss_pm_domain_off (vfe->camss, vfe->id); } vfe->power_count--;
drivers/media/platform/qcom/camss/camss.c +55 -39
124 lines not on this page · raw message
drivers/media/platform/qcom/camss/camss.h +5 -7
@@ -57,9 +57,9 @@ struct resources_ispif { };enum pm_domain { -PM_DOMAIN_VFE0 , -PM_DOMAIN_VFE1 , -PM_DOMAIN_COUNT +PM_DOMAIN_VFE0 =0 , +PM_DOMAIN_VFE1 =1 , +PM_DOMAIN_CAMSS_COUNT =2 ,/* CAMSS series of ISPs */ };enum camss_version {
@@ -83,8 +83,8 @@ struct camss {int vfe_num;struct vfe_device *vfe;atomic_t ref_count; -struct device *genpd[PM_DOMAIN_COUNT ]; -struct device_link *genpd_link[PM_DOMAIN_COUNT ]; +struct device *genpd[PM_DOMAIN_CAMSS_COUNT ]; +struct device_link *genpd_link[PM_DOMAIN_CAMSS_COUNT ]; };struct camss_camera_interface {
@@ -110,8 +110,6 @@ int camss_enable_clocks(int nclocks, struct camss_clock *clock,void camss_disable_clocks (int nclocks,struct camss_clock *clock);struct media_entity *camss_find_sensor (struct media_entity *entity);int camss_get_pixel_clock (struct media_entity *entity,u32 *pixel_clock); -int camss_pm_domain_on (struct camss *camss,int id); -void camss_pm_domain_off (struct camss *camss,int id);void camss_delete (struct camss *camss);#endif /* QC_MSM_CAMSS_H */
Signature · 1 line
2.27.0
PATCH v4 13/22 media: camss: Enable SDM845
In reply to Robert FossEnable support for SDM845 based Titan 170 ISPs.
--- drivers/media/platform/qcom/camss/camss.c | 17 +++++++++++++++++ drivers/media/platform/qcom/camss/camss.h | 6 ++++-- 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/camss/camss.c +17 -0
@@ -897,6 +897,12 @@ static int camss_init_subdevices(struct camss *camss) csid_res = csid_res_660; ispif_res = &ispif_res_660; vfe_res = vfe_res_660; + }else if (camss->version ==CAMSS_845 ) { + csiphy_res = csiphy_res_845; + csid_res = csid_res_845; +/* Titan VFEs don't have an ISPIF */ + ispif_res =NULL ; + vfe_res = vfe_res_845; }else {return -EINVAL ; }
@@ -1203,6 +1209,8 @@ static int camss_configure_pd(struct camss *camss)if (camss->version == CAMSS_8x96 || camss->version ==CAMSS_660 ) nbr_pm_domains =PM_DOMAIN_CAMSS_COUNT ; +else if (camss->version ==CAMSS_845 ) + nbr_pm_domains =PM_DOMAIN_TITAN_COUNT ;for (i =0 ; i < nbr_pm_domains; i++) { camss->genpd[i] =dev_pm_domain_attach_by_id (camss->dev, i);
@@ -1271,6 +1279,12 @@ static int camss_probe(struct platform_device *pdev) camss->csiphy_num =3 ; camss->csid_num =4 ; camss->vfe_num =2 ; + }else if (of_device_is_compatible (dev->of_node, +"qcom,sdm845-camss" )) { + camss->version =CAMSS_845 ; + camss->csiphy_num =4 ; + camss->csid_num =3 ; + camss->vfe_num =3 ; }else { ret = -EINVAL ; goto err_free;
@@ -1402,6 +1416,8 @@ void camss_delete(struct camss *camss)if (camss->version == CAMSS_8x96 || camss->version ==CAMSS_660 ) nbr_pm_domains =PM_DOMAIN_CAMSS_COUNT ; +else if (camss->version ==CAMSS_845 ) + nbr_pm_domains =PM_DOMAIN_TITAN_COUNT ;for (i =0 ; i < nbr_pm_domains; i++) {device_link_del (camss->genpd_link[i]);
@@ -1435,6 +1451,7 @@ static const struct of_device_id camss_dt_match[] = { { .compatible = "qcom,msm8916-camss" }, { .compatible = "qcom,msm8996-camss" }, { .compatible = "qcom,sdm660-camss" }, + { .compatible = "qcom,sdm845-camss" }, { } };
drivers/media/platform/qcom/camss/camss.h +4 -2
@@ -60,6 +60,8 @@ enum pm_domain {PM_DOMAIN_VFE0 =0 ,PM_DOMAIN_VFE1 =1 ,PM_DOMAIN_CAMSS_COUNT =2 ,/* CAMSS series of ISPs */ +PM_DOMAIN_VFELITE =2 ,/* VFELITE / TOP GDSC */ + PM_DOMAIN_TITAN_COUNT = 3, /* Titan series of ISPs */ }; enum camss_version {
@@ -83,8 +85,8 @@ struct camss {int vfe_num;struct vfe_device *vfe;atomic_t ref_count; -struct device *genpd[PM_DOMAIN_CAMSS_COUNT ]; -struct device_link *genpd_link[PM_DOMAIN_CAMSS_COUNT ]; +struct device *genpd[PM_DOMAIN_TITAN_COUNT ]; +struct device_link *genpd_link[PM_DOMAIN_TITAN_COUNT ]; };struct camss_camera_interface {
Signature · 1 line
2.27.0
PATCH v4 14/22 dt-bindings: media: camss: Add qcom,msm8916-camss binding
In reply to Robert FossAdd bindings for qcom,msm8916-camss in order to support the camera subsystem on MSM8916.
---
Changes since v2:
- Remove redundant descriptions
- Add power domain description
- Make clock-lanes a constant
- Add max & minItems to data-lanes
- Remove ports requirement - endpoint & reg
- Rework to conform to new port schema
.../bindings/media/qcom,msm8916-camss.yaml | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/qcom,msm8916-camss.yaml
Documentation/devicetree/bindings/media/qcom,msm8916-camss.yaml new file +256 -0
@@ -0,0 +1,256 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) + +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/media/qcom,msm8916-camss.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Qualcomm CAMSS ISP + +maintainers: + - Robert Foss <[email protected]> + - Todor Tomov <[email protected]> + +description: | + The CAMSS IP is a CSI decoder and ISP present on Qualcomm platforms + +properties: + compatible: + const: qcom,msm8916-camss + + clocks: + minItems: 19 + maxItems: 19 + + clock-names: + items: + - const: top_ahb + - const: ispif_ahb + - const: csiphy0_timer + - const: csiphy1_timer + - const: csi0_ahb + - const: csi0 + - const: csi0_phy + - const: csi0_pix + - const: csi0_rdi + - const: csi1_ahb + - const: csi1 + - const: csi1_phy + - const: csi1_pix + - const: csi1_rdi + - const: ahb + - const: vfe0 + - const: csi_vfe0 + - const: vfe_ahb + - const: vfe_axi + + interrupts: + minItems: 6 + maxItems: 6 + + interrupt-names: + items: + - const: csiphy0 + - const: csiphy1 + - const: csid0 + - const: csid1 + - const: ispif + - const: vfe0 + + iommus: + maxItems: 1 + + power-domains: + items: + - description: VFE GDSC - Video Front End, Global Distributed Switch Controller. + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + description: + CSI input ports. + + properties: + port@0: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 1 + + data-lanes: + description: + An array of physical data lanes indexes. + Position of an entry determines the logical + lane number, while the value of an entry + indicates physical lane index. Lane swapping + is supported. Physical lane indexes; + 0, 2, 3, 4. + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 1 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + reg: + minItems: 9 + maxItems: 9 + + reg-names: + items: + - const: csiphy0 + - const: csiphy0_clk_mux + - const: csiphy1 + - const: csiphy1_clk_mux + - const: csid0 + - const: csid1 + - const: ispif + - const: csi_clk_mux + - const: vfe0 + + vdda-supply: + description: + Definition of the regulator used as analog power supply. + +required: + - clock-names + - clocks + - compatible + - interrupt-names + - interrupts + - iommus + - power-domains + - reg + - reg-names + - vdda-supply + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/qcom,gcc-msm8916.h> + + camss: camss@1b00000 { + compatible = "qcom,msm8916-camss"; + + clocks = <&gcc GCC_CAMSS_TOP_AHB_CLK>, + <&gcc GCC_CAMSS_ISPIF_AHB_CLK>, + <&gcc GCC_CAMSS_CSI0PHYTIMER_CLK>, + <&gcc GCC_CAMSS_CSI1PHYTIMER_CLK>, + <&gcc GCC_CAMSS_CSI0_AHB_CLK>, + <&gcc GCC_CAMSS_CSI0_CLK>, + <&gcc GCC_CAMSS_CSI0PHY_CLK>, + <&gcc GCC_CAMSS_CSI0PIX_CLK>, + <&gcc GCC_CAMSS_CSI0RDI_CLK>, + <&gcc GCC_CAMSS_CSI1_AHB_CLK>, + <&gcc GCC_CAMSS_CSI1_CLK>, + <&gcc GCC_CAMSS_CSI1PHY_CLK>, + <&gcc GCC_CAMSS_CSI1PIX_CLK>, + <&gcc GCC_CAMSS_CSI1RDI_CLK>, + <&gcc GCC_CAMSS_AHB_CLK>, + <&gcc GCC_CAMSS_VFE0_CLK>, + <&gcc GCC_CAMSS_CSI_VFE0_CLK>, + <&gcc GCC_CAMSS_VFE_AHB_CLK>, + <&gcc GCC_CAMSS_VFE_AXI_CLK>; + + clock-names = "top_ahb", + "ispif_ahb", + "csiphy0_timer", + "csiphy1_timer", + "csi0_ahb", + "csi0", + "csi0_phy", + "csi0_pix", + "csi0_rdi", + "csi1_ahb", + "csi1", + "csi1_phy", + "csi1_pix", + "csi1_rdi", + "ahb", + "vfe0", + "csi_vfe0", + "vfe_ahb", + "vfe_axi"; + + interrupts = <GIC_SPI 78 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 79 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 51 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 52 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 55 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 57 IRQ_TYPE_EDGE_RISING>; + + interrupt-names = "csiphy0", + "csiphy1", + "csid0", + "csid1", + "ispif", + "vfe0"; + + iommus = <&apps_iommu 3>; + + power-domains = <&gcc VFE_GDSC>; + + reg = <0x01b0ac00 0x200>, + <0x01b00030 0x4>, + <0x01b0b000 0x200>, + <0x01b00038 0x4>, + <0x01b08000 0x100>, + <0x01b08400 0x100>, + <0x01b0a000 0x500>, + <0x01b00020 0x10>, + <0x01b10000 0x1000>; + + reg-names = "csiphy0", + "csiphy0_clk_mux", + "csiphy1", + "csiphy1_clk_mux", + "csid0", + "csid1", + "ispif", + "csi_clk_mux", + "vfe0"; + + vdda-supply = <®_2v8>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + }; + + };
Signature · 1 line
2.27.0
Re: [PATCH v4 14/22] dt-bindings: media: camss: Add qcom,msm8916-camss binding
Quoted 15 lines · Robert Foss
Add bindings for qcom,msm8916-camss in order to support the camera subsystem on MSM8916.
Signed-off-by Robert Foss <[email protected]>---
Changes since v2:
- Remove redundant descriptions
- Add power domain description
- Make clock-lanes a constant
- Add max & minItems to data-lanes
- Remove ports requirement - endpoint & reg
- Rework to conform to new port schema
Quoted 3 lines
.../bindings/media/qcom,msm8916-camss.yaml | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/qcom,msm8916-camss.yaml
PATCH v4 15/22 dt-bindings: media: camss: Add qcom,msm8996-camss binding
In reply to Robert FossAdd bindings for qcom,msm8996-camss in order to support the camera subsystem on MSM8996.
---
Changes since v2
- Rob: Add new line at end of file
- Rob: Remove redundant descriptions
- Rob: Add power domain description
- Rob: Make clock-lanes a constant
- Rob: Rework to conform to new port schema
- Add max & minItems to data-lanes
- Remove ports requirement - endpoint & reg
.../bindings/media/qcom,msm8996-camss.yaml | 387 ++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/qcom,msm8996-camss.yaml
Documentation/devicetree/bindings/media/qcom,msm8996-camss.yaml new file +387 -0
@@ -0,0 +1,387 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) + +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/media/qcom,msm8996-camss.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Qualcomm CAMSS ISP + +maintainers: + - Robert Foss <[email protected]> + - Todor Tomov <[email protected]> + +description: | + The CAMSS IP is a CSI decoder and ISP present on Qualcomm platforms + +properties: + compatible: + const: qcom,msm8996-camss + + clocks: + minItems: 36 + maxItems: 36 + + clock-names: + items: + - const: top_ahb + - const: ispif_ahb + - const: csiphy0_timer + - const: csiphy1_timer + - const: csiphy2_timer + - const: csi0_ahb + - const: csi0 + - const: csi0_phy + - const: csi0_pix + - const: csi0_rdi + - const: csi1_ahb + - const: csi1 + - const: csi1_phy + - const: csi1_pix + - const: csi1_rdi + - const: csi2_ahb + - const: csi2 + - const: csi2_phy + - const: csi2_pix + - const: csi2_rdi + - const: csi3_ahb + - const: csi3 + - const: csi3_phy + - const: csi3_pix + - const: csi3_rdi + - const: ahb + - const: vfe0 + - const: csi_vfe0 + - const: vfe0_ahb + - const: vfe0_stream + - const: vfe1 + - const: csi_vfe1 + - const: vfe1_ahb + - const: vfe1_stream + - const: vfe_ahb + - const: vfe_axi + + interrupts: + minItems: 10 + maxItems: 10 + + interrupt-names: + items: + - const: csiphy0 + - const: csiphy1 + - const: csiphy2 + - const: csid0 + - const: csid1 + - const: csid2 + - const: csid3 + - const: ispif + - const: vfe0 + - const: vfe1 + + iommus: + maxItems: 4 + + power-domains: + items: + - description: VFE0 GDSC - Video Front End, Global Distributed Switch Controller. + - description: VFE1 GDSC - Video Front End, Global Distributed Switch Controller. + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + description: + CSI input ports. + + properties: + port@0: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 7 + + data-lanes: + description: + An array of physical data lanes indexes. + Position of an entry determines the logical + lane number, while the value of an entry + indicates physical lane index. Lane swapping + is supported. Physical lane indexes are; + 0, 1, 2, 3 + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 7 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@2: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 7 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@3: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 7 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + reg: + minItems: 14 + maxItems: 14 + + reg-names: + items: + - const: csiphy0 + - const: csiphy0_clk_mux + - const: csiphy1 + - const: csiphy1_clk_mux + - const: csiphy2 + - const: csiphy2_clk_mux + - const: csid0 + - const: csid1 + - const: csid2 + - const: csid3 + - const: ispif + - const: csi_clk_mux + - const: vfe0 + - const: vfe1 + + vdda-supply: + description: + Definition of the regulator used as analog power supply. + +required: + - clock-names + - clocks + - compatible + - interrupt-names + - interrupts + - iommus + - power-domains + - reg + - reg-names + - vdda-supply + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/qcom,gcc-msm8996.h> + #include <dt-bindings/clock/qcom,mmcc-msm8996.h> + + camss: camss@a00000 { + compatible = "qcom,msm8996-camss"; + + clocks = <&mmcc CAMSS_TOP_AHB_CLK>, + <&mmcc CAMSS_ISPIF_AHB_CLK>, + <&mmcc CAMSS_CSI0PHYTIMER_CLK>, + <&mmcc CAMSS_CSI1PHYTIMER_CLK>, + <&mmcc CAMSS_CSI2PHYTIMER_CLK>, + <&mmcc CAMSS_CSI0_AHB_CLK>, + <&mmcc CAMSS_CSI0_CLK>, + <&mmcc CAMSS_CSI0PHY_CLK>, + <&mmcc CAMSS_CSI0PIX_CLK>, + <&mmcc CAMSS_CSI0RDI_CLK>, + <&mmcc CAMSS_CSI1_AHB_CLK>, + <&mmcc CAMSS_CSI1_CLK>, + <&mmcc CAMSS_CSI1PHY_CLK>, + <&mmcc CAMSS_CSI1PIX_CLK>, + <&mmcc CAMSS_CSI1RDI_CLK>, + <&mmcc CAMSS_CSI2_AHB_CLK>, + <&mmcc CAMSS_CSI2_CLK>, + <&mmcc CAMSS_CSI2PHY_CLK>, + <&mmcc CAMSS_CSI2PIX_CLK>, + <&mmcc CAMSS_CSI2RDI_CLK>, + <&mmcc CAMSS_CSI3_AHB_CLK>, + <&mmcc CAMSS_CSI3_CLK>, + <&mmcc CAMSS_CSI3PHY_CLK>, + <&mmcc CAMSS_CSI3PIX_CLK>, + <&mmcc CAMSS_CSI3RDI_CLK>, + <&mmcc CAMSS_AHB_CLK>, + <&mmcc CAMSS_VFE0_CLK>, + <&mmcc CAMSS_CSI_VFE0_CLK>, + <&mmcc CAMSS_VFE0_AHB_CLK>, + <&mmcc CAMSS_VFE0_STREAM_CLK>, + <&mmcc CAMSS_VFE1_CLK>, + <&mmcc CAMSS_CSI_VFE1_CLK>, + <&mmcc CAMSS_VFE1_AHB_CLK>, + <&mmcc CAMSS_VFE1_STREAM_CLK>, + <&mmcc CAMSS_VFE_AHB_CLK>, + <&mmcc CAMSS_VFE_AXI_CLK>; + + clock-names = "top_ahb", + "ispif_ahb", + "csiphy0_timer", + "csiphy1_timer", + "csiphy2_timer", + "csi0_ahb", + "csi0", + "csi0_phy", + "csi0_pix", + "csi0_rdi", + "csi1_ahb", + "csi1", + "csi1_phy", + "csi1_pix", + "csi1_rdi", + "csi2_ahb", + "csi2", + "csi2_phy", + "csi2_pix", + "csi2_rdi", + "csi3_ahb", + "csi3", + "csi3_phy", + "csi3_pix", + "csi3_rdi", + "ahb", + "vfe0", + "csi_vfe0", + "vfe0_ahb", + "vfe0_stream", + "vfe1", + "csi_vfe1", + "vfe1_ahb", + "vfe1_stream", + "vfe_ahb", + "vfe_axi"; + + interrupts = <GIC_SPI 78 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 79 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 80 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 296 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 297 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 298 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 299 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 309 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 314 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 315 IRQ_TYPE_EDGE_RISING>; + + interrupt-names = "csiphy0", + "csiphy1", + "csiphy2", + "csid0", + "csid1", + "csid2", + "csid3", + "ispif", + "vfe0", + "vfe1"; + + iommus = <&vfe_smmu 0>, + <&vfe_smmu 1>, + <&vfe_smmu 2>, + <&vfe_smmu 3>; + + power-domains = <&mmcc VFE0_GDSC>, + <&mmcc VFE1_GDSC>; + + reg = <0x00a34000 0x1000>, + <0x00a00030 0x4>, + <0x00a35000 0x1000>, + <0x00a00038 0x4>, + <0x00a36000 0x1000>, + <0x00a00040 0x4>, + <0x00a30000 0x100>, + <0x00a30400 0x100>, + <0x00a30800 0x100>, + <0x00a30c00 0x100>, + <0x00a31000 0x500>, + <0x00a00020 0x10>, + <0x00a10000 0x1000>, + <0x00a14000 0x1000>; + + reg-names = "csiphy0", + "csiphy0_clk_mux", + "csiphy1", + "csiphy1_clk_mux", + "csiphy2", + "csiphy2_clk_mux", + "csid0", + "csid1", + "csid2", + "csid3", + "ispif", + "csi_clk_mux", + "vfe0", + "vfe1"; + + vdda-supply = <®_2v8>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + }; + };
Signature · 1 line
2.27.0
Re: [PATCH v4 15/22] dt-bindings: media: camss: Add qcom,msm8996-camss binding
Quoted 16 lines · Robert Foss
Add bindings for qcom,msm8996-camss in order to support the camera subsystem on MSM8996.
Signed-off-by Robert Foss <[email protected]>---
Changes since v2
- Rob: Add new line at end of file
- Rob: Remove redundant descriptions
- Rob: Add power domain description
- Rob: Make clock-lanes a constant
- Rob: Rework to conform to new port schema
- Add max & minItems to data-lanes
- Remove ports requirement - endpoint & reg
Quoted 4 lines
.../bindings/media/qcom,msm8996-camss.yaml | 387 ++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/qcom,msm8996-camss.yaml
PATCH v4 16/22 dt-bindings: media: camss: Add qcom,sdm660-camss binding
In reply to Robert FossAdd bindings for qcom,sdm660-camss in order to support the camera subsystem on SDM630/660 and SDA variants.
---
Changes since v2
- Rob: Add new line at end of file
- Rob: Remove redundant descriptions
- Rob: Add power domain description
- Rob: Make clock-lanes a constant
- Rob: Rework to conform to new port schema
- Add max & minItems to data-lanes
- Remove ports requirement - endpoint & reg
- Added Angelo as binding maintainer
- Removed Todor as binding maintainer
Changes since v3:
- Rob: Added r-b
.../bindings/media/qcom,sdm660-camss.yaml | 398 ++++++++++++++++++ 1 file changed, 398 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/qcom,sdm660-camss.yaml
Documentation/devicetree/bindings/media/qcom,sdm660-camss.yaml new file +398 -0
@@ -0,0 +1,398 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) + +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/media/qcom,sdm660-camss.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Qualcomm CAMSS ISP + +maintainers: + - Robert Foss <[email protected]> + - AngeloGioacchino Del Regno <[email protected]> + +description: | + The CAMSS IP is a CSI decoder and ISP present on Qualcomm platforms + +properties: + compatible: + const: qcom,sdm660-camss + + clocks: + minItems: 42 + maxItems: 42 + + clock-names: + items: + - const: ahb + - const: cphy_csid0 + - const: cphy_csid1 + - const: cphy_csid2 + - const: cphy_csid3 + - const: csi0_ahb + - const: csi0 + - const: csi0_phy + - const: csi0_pix + - const: csi0_rdi + - const: csi1_ahb + - const: csi1 + - const: csi1_phy + - const: csi1_pix + - const: csi1_rdi + - const: csi2_ahb + - const: csi2 + - const: csi2_phy + - const: csi2_pix + - const: csi2_rdi + - const: csi3_ahb + - const: csi3 + - const: csi3_phy + - const: csi3_pix + - const: csi3_rdi + - const: csiphy0_timer + - const: csiphy1_timer + - const: csiphy2_timer + - const: csiphy_ahb2crif + - const: csi_vfe0 + - const: csi_vfe1 + - const: ispif_ahb + - const: throttle_axi + - const: top_ahb + - const: vfe0_ahb + - const: vfe0 + - const: vfe0_stream + - const: vfe1_ahb + - const: vfe1 + - const: vfe1_stream + - const: vfe_ahb + - const: vfe_axi + + interrupts: + minItems: 10 + maxItems: 10 + + interrupt-names: + items: + - const: csid0 + - const: csid1 + - const: csid2 + - const: csid3 + - const: csiphy0 + - const: csiphy1 + - const: csiphy2 + - const: ispif + - const: vfe0 + - const: vfe1 + + iommus: + maxItems: 4 + + power-domains: + items: + - description: VFE0 GDSC - Video Front End, Global Distributed Switch Controller. + - description: VFE1 GDSC - Video Front End, Global Distributed Switch Controller. + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + description: + CSI input ports. + + properties: + port@0: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 7 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 7 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@2: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 7 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@3: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + items: + - const: 7 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + reg: + minItems: 14 + maxItems: 14 + + reg-names: + items: + - const: csi_clk_mux + - const: csid0 + - const: csid1 + - const: csid2 + - const: csid3 + - const: csiphy0 + - const: csiphy0_clk_mux + - const: csiphy1 + - const: csiphy1_clk_mux + - const: csiphy2 + - const: csiphy2_clk_mux + - const: ispif + - const: vfe0 + - const: vfe1 + + vdda-supply: + description: + Definition of the regulator used as analog power supply. + +required: + - clock-names + - clocks + - compatible + - interrupt-names + - interrupts + - iommus + - power-domains + - reg + - reg-names + - vdda-supply + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/qcom,gcc-sdm660.h> + #include <dt-bindings/clock/qcom,mmcc-sdm660.h> + + camss: camss@ca00000 { + compatible = "qcom,sdm660-camss"; + + clocks = <&mmcc CAMSS_AHB_CLK>, + <&mmcc CAMSS_CPHY_CSID0_CLK>, + <&mmcc CAMSS_CPHY_CSID1_CLK>, + <&mmcc CAMSS_CPHY_CSID2_CLK>, + <&mmcc CAMSS_CPHY_CSID3_CLK>, + <&mmcc CAMSS_CSI0_AHB_CLK>, + <&mmcc CAMSS_CSI0_CLK>, + <&mmcc CAMSS_CPHY_CSID0_CLK>, + <&mmcc CAMSS_CSI0PIX_CLK>, + <&mmcc CAMSS_CSI0RDI_CLK>, + <&mmcc CAMSS_CSI1_AHB_CLK>, + <&mmcc CAMSS_CSI1_CLK>, + <&mmcc CAMSS_CPHY_CSID1_CLK>, + <&mmcc CAMSS_CSI1PIX_CLK>, + <&mmcc CAMSS_CSI1RDI_CLK>, + <&mmcc CAMSS_CSI2_AHB_CLK>, + <&mmcc CAMSS_CSI2_CLK>, + <&mmcc CAMSS_CPHY_CSID2_CLK>, + <&mmcc CAMSS_CSI2PIX_CLK>, + <&mmcc CAMSS_CSI2RDI_CLK>, + <&mmcc CAMSS_CSI3_AHB_CLK>, + <&mmcc CAMSS_CSI3_CLK>, + <&mmcc CAMSS_CPHY_CSID3_CLK>, + <&mmcc CAMSS_CSI3PIX_CLK>, + <&mmcc CAMSS_CSI3RDI_CLK>, + <&mmcc CAMSS_CSI0PHYTIMER_CLK>, + <&mmcc CAMSS_CSI1PHYTIMER_CLK>, + <&mmcc CAMSS_CSI2PHYTIMER_CLK>, + <&mmcc CSIPHY_AHB2CRIF_CLK>, + <&mmcc CAMSS_CSI_VFE0_CLK>, + <&mmcc CAMSS_CSI_VFE1_CLK>, + <&mmcc CAMSS_ISPIF_AHB_CLK>, + <&mmcc THROTTLE_CAMSS_AXI_CLK>, + <&mmcc CAMSS_TOP_AHB_CLK>, + <&mmcc CAMSS_VFE0_AHB_CLK>, + <&mmcc CAMSS_VFE0_CLK>, + <&mmcc CAMSS_VFE0_STREAM_CLK>, + <&mmcc CAMSS_VFE1_AHB_CLK>, + <&mmcc CAMSS_VFE1_CLK>, + <&mmcc CAMSS_VFE1_STREAM_CLK>, + <&mmcc CAMSS_VFE_VBIF_AHB_CLK>, + <&mmcc CAMSS_VFE_VBIF_AXI_CLK>; + + clock-names = "ahb", + "cphy_csid0", + "cphy_csid1", + "cphy_csid2", + "cphy_csid3", + "csi0_ahb", + "csi0", + "csi0_phy", + "csi0_pix", + "csi0_rdi", + "csi1_ahb", + "csi1", + "csi1_phy", + "csi1_pix", + "csi1_rdi", + "csi2_ahb", + "csi2", + "csi2_phy", + "csi2_pix", + "csi2_rdi", + "csi3_ahb", + "csi3", + "csi3_phy", + "csi3_pix", + "csi3_rdi", + "csiphy0_timer", + "csiphy1_timer", + "csiphy2_timer", + "csiphy_ahb2crif", + "csi_vfe0", + "csi_vfe1", + "ispif_ahb", + "throttle_axi", + "top_ahb", + "vfe0_ahb", + "vfe0", + "vfe0_stream", + "vfe1_ahb", + "vfe1", + "vfe1_stream", + "vfe_ahb", + "vfe_axi"; + + interrupts = <GIC_SPI 296 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 297 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 298 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 299 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 78 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 79 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 80 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 309 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 314 IRQ_TYPE_EDGE_RISING>, + <GIC_SPI 315 IRQ_TYPE_EDGE_RISING>; + + interrupt-names = "csid0", + "csid1", + "csid2", + "csid3", + "csiphy0", + "csiphy1", + "csiphy2", + "ispif", + "vfe0", + "vfe1"; + + iommus = <&mmss_smmu 0xc00>, + <&mmss_smmu 0xc01>, + <&mmss_smmu 0xc02>, + <&mmss_smmu 0xc03>; + + power-domains = <&mmcc CAMSS_VFE0_GDSC>, + <&mmcc CAMSS_VFE1_GDSC>; + + reg = <0x0ca00020 0x10>, + <0x0ca30000 0x100>, + <0x0ca30400 0x100>, + <0x0ca30800 0x100>, + <0x0ca30c00 0x100>, + <0x0c824000 0x1000>, + <0x0ca00120 0x4>, + <0x0c825000 0x1000>, + <0x0ca00124 0x4>, + <0x0c826000 0x1000>, + <0x0ca00128 0x4>, + <0x0ca31000 0x500>, + <0x0ca10000 0x1000>, + <0x0ca14000 0x1000>; + + reg-names = "csi_clk_mux", + "csid0", + "csid1", + "csid2", + "csid3", + "csiphy0", + "csiphy0_clk_mux", + "csiphy1", + "csiphy1_clk_mux", + "csiphy2", + "csiphy2_clk_mux", + "ispif", + "vfe0", + "vfe1"; + + vdda-supply = <®_2v8>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + }; + };
Signature · 1 line
2.27.0
PATCH v4 17/22 dt-bindings: media: camss: Add qcom,sdm845-camss binding
In reply to Robert FossAdd bindings for qcom,sdm845-camss in order to support the camera subsystem for SDM845.
---
Changes since v2
- Rob: Removed extra empty lines at end of file
- Rob: Add new line at end of file
- Rob: Remove redundant descriptions
- Rob: Add power domain description
- Rob: Make clock-lanes a constant
- Rob: Rework to conform to new port schema
- Add max & minItems to data-lanes
- Remove ports requirement - endpoint & reg
- Add proper commit message
- Remove Todor as binding maintainer
Changes since v3
- Fixed ordering of IRQs
.../bindings/media/qcom,sdm845-camss.yaml | 370 ++++++++++++++++++ 1 file changed, 370 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/qcom,sdm845-camss.yaml
Documentation/devicetree/bindings/media/qcom,sdm845-camss.yaml new file +370 -0
@@ -0,0 +1,370 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) + +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/media/qcom,sdm845-camss.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Qualcomm CAMSS ISP + +maintainers: + - Robert Foss <[email protected]> + +description: | + The CAMSS IP is a CSI decoder and ISP present on Qualcomm platforms + +properties: + compatible: + const: qcom,sdm845-camss + + clocks: + minItems: 36 + maxItems: 36 + + clock-names: + items: + - const: camnoc_axi + - const: cpas_ahb + - const: cphy_rx_src + - const: csi0 + - const: csi0_src + - const: csi1 + - const: csi1_src + - const: csi2 + - const: csi2_src + - const: csiphy0 + - const: csiphy0_timer + - const: csiphy0_timer_src + - const: csiphy1 + - const: csiphy1_timer + - const: csiphy1_timer_src + - const: csiphy2 + - const: csiphy2_timer + - const: csiphy2_timer_src + - const: csiphy3 + - const: csiphy3_timer + - const: csiphy3_timer_src + - const: gcc_camera_ahb + - const: gcc_camera_axi + - const: slow_ahb_src + - const: soc_ahb + - const: vfe0_axi + - const: vfe0 + - const: vfe0_cphy_rx + - const: vfe0_src + - const: vfe1_axi + - const: vfe1 + - const: vfe1_cphy_rx + - const: vfe1_src + - const: vfe_lite + - const: vfe_lite_cphy_rx + - const: vfe_lite_src + + interrupts: + minItems: 10 + maxItems: 10 + + interrupt-names: + items: + - const: csid0 + - const: csid1 + - const: csid2 + - const: csiphy0 + - const: csiphy1 + - const: csiphy2 + - const: csiphy3 + - const: vfe0 + - const: vfe1 + - const: vfe_lite + + iommus: + maxItems: 4 + + power-domains: + items: + - description: IFE0 GDSC - Image Front End, Global Distributed Switch Controller. + - description: IFE1 GDSC - Image Front End, Global Distributed Switch Controller. + - description: Titan GDSC - Titan ISP Block, Global Distributed Switch Controller. + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + description: + CSI input ports. + + properties: + port@0: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + maxItems: 1 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + maxItems: 1 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@2: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + maxItems: 1 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + port@3: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: + Input port for receiving CSI data. + + properties: + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + properties: + clock-lanes: + maxItems: 1 + + data-lanes: + minItems: 1 + maxItems: 4 + + required: + - clock-lanes + - data-lanes + + reg: + minItems: 10 + maxItems: 10 + + reg-names: + items: + - const: csid0 + - const: csid1 + - const: csid2 + - const: csiphy0 + - const: csiphy1 + - const: csiphy2 + - const: csiphy3 + - const: vfe0 + - const: vfe1 + - const: vfe_lite + + vdda-supply: + description: + Definition of the regulator used as analog power supply. + +required: + - clock-names + - clocks + - compatible + - interrupt-names + - interrupts + - iommus + - power-domains + - reg + - reg-names + - vdda-supply + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/clock/qcom,camcc-sdm845.h> + #include <dt-bindings/clock/qcom,gcc-sdm845.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + camss: camss@a00000 { + compatible = "qcom,sdm845-camss"; + + clocks = <&clock_camcc CAM_CC_CAMNOC_AXI_CLK>, + <&clock_camcc CAM_CC_CPAS_AHB_CLK>, + <&clock_camcc CAM_CC_CPHY_RX_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_0_CSID_CLK>, + <&clock_camcc CAM_CC_IFE_0_CSID_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_1_CSID_CLK>, + <&clock_camcc CAM_CC_IFE_1_CSID_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_LITE_CSID_CLK>, + <&clock_camcc CAM_CC_IFE_LITE_CSID_CLK_SRC>, + <&clock_camcc CAM_CC_CSIPHY0_CLK>, + <&clock_camcc CAM_CC_CSI0PHYTIMER_CLK>, + <&clock_camcc CAM_CC_CSI0PHYTIMER_CLK_SRC>, + <&clock_camcc CAM_CC_CSIPHY1_CLK>, + <&clock_camcc CAM_CC_CSI1PHYTIMER_CLK>, + <&clock_camcc CAM_CC_CSI1PHYTIMER_CLK_SRC>, + <&clock_camcc CAM_CC_CSIPHY2_CLK>, + <&clock_camcc CAM_CC_CSI2PHYTIMER_CLK>, + <&clock_camcc CAM_CC_CSI2PHYTIMER_CLK_SRC>, + <&clock_camcc CAM_CC_CSIPHY3_CLK>, + <&clock_camcc CAM_CC_CSI3PHYTIMER_CLK>, + <&clock_camcc CAM_CC_CSI3PHYTIMER_CLK_SRC>, + <&gcc GCC_CAMERA_AHB_CLK>, + <&gcc GCC_CAMERA_AXI_CLK>, + <&clock_camcc CAM_CC_SLOW_AHB_CLK_SRC>, + <&clock_camcc CAM_CC_SOC_AHB_CLK>, + <&clock_camcc CAM_CC_IFE_0_AXI_CLK>, + <&clock_camcc CAM_CC_IFE_0_CLK>, + <&clock_camcc CAM_CC_IFE_0_CPHY_RX_CLK>, + <&clock_camcc CAM_CC_IFE_0_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_1_AXI_CLK>, + <&clock_camcc CAM_CC_IFE_1_CLK>, + <&clock_camcc CAM_CC_IFE_1_CPHY_RX_CLK>, + <&clock_camcc CAM_CC_IFE_1_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_LITE_CLK>, + <&clock_camcc CAM_CC_IFE_LITE_CPHY_RX_CLK>, + <&clock_camcc CAM_CC_IFE_LITE_CLK_SRC>; + + clock-names = "camnoc_axi", + "cpas_ahb", + "cphy_rx_src", + "csi0", + "csi0_src", + "csi1", + "csi1_src", + "csi2", + "csi2_src", + "csiphy0", + "csiphy0_timer", + "csiphy0_timer_src", + "csiphy1", + "csiphy1_timer", + "csiphy1_timer_src", + "csiphy2", + "csiphy2_timer", + "csiphy2_timer_src", + "csiphy3", + "csiphy3_timer", + "csiphy3_timer_src", + "gcc_camera_ahb", + "gcc_camera_axi", + "slow_ahb_src", + "soc_ahb", + "vfe0_axi", + "vfe0", + "vfe0_cphy_rx", + "vfe0_src", + "vfe1_axi", + "vfe1", + "vfe1_cphy_rx", + "vfe1_src", + "vfe_lite", + "vfe_lite_cphy_rx", + "vfe_lite_src"; + + interrupts = <GIC_SPI 464 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 466 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 468 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 477 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 478 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 479 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 448 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 465 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 467 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 469 IRQ_TYPE_LEVEL_HIGH>; + + interrupt-names = "csid0", + "csid1", + "csid2", + "csiphy0", + "csiphy1", + "csiphy2", + "csiphy3", + "vfe0", + "vfe1", + "vfe_lite"; + + iommus = <&apps_smmu 0x0808 0x0>, + <&apps_smmu 0x0810 0x8>, + <&apps_smmu 0x0c08 0x0>, + <&apps_smmu 0x0c10 0x8>; + + power-domains = <&clock_camcc IFE_0_GDSC>, + <&clock_camcc IFE_1_GDSC>, + <&clock_camcc TITAN_TOP_GDSC>; + + reg = <0 0xacb3000 0 0x1000>, + <0 0xacba000 0 0x1000>, + <0 0xacc8000 0 0x1000>, + <0 0xac65000 0 0x1000>, + <0 0xac66000 0 0x1000>, + <0 0xac67000 0 0x1000>, + <0 0xac68000 0 0x1000>, + <0 0xacaf000 0 0x4000>, + <0 0xacb6000 0 0x4000>, + <0 0xacc4000 0 0x4000>; + + reg-names = "csid0", + "csid1", + "csid2", + "csiphy0", + "csiphy1", + "csiphy2", + "csiphy3", + "vfe0", + "vfe1", + "vfe_lite"; + + vdda-supply = <®_2v8>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + }; + }; + };
Signature · 1 line
2.27.0
Re: [PATCH v4 17/22] dt-bindings: media: camss: Add qcom,sdm845-camss binding
Quoted 18 lines · Robert Foss
Add bindings for qcom,sdm845-camss in order to support the camera subsystem for SDM845.
Signed-off-by Robert Foss <[email protected]>---
Changes since v2
- Rob: Removed extra empty lines at end of file
- Rob: Add new line at end of file
- Rob: Remove redundant descriptions
- Rob: Add power domain description
- Rob: Make clock-lanes a constant
- Rob: Rework to conform to new port schema
- Add max & minItems to data-lanes
- Remove ports requirement - endpoint & reg
- Add proper commit message
- Remove Todor as binding maintainer
Quoted 8 lines
Changes since v3
- Fixed ordering of IRQs.../bindings/media/qcom,sdm845-camss.yaml | 370 ++++++++++++++++++ 1 file changed, 370 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/qcom,sdm845-camss.yaml
PATCH v4 18/22 MAINTAINERS: Change CAMSS documentation to use dtschema bindings
In reply to Robert FossDue to the complexity of describing multiple hardware generations in one document, switch to using separate dt-bindings.
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -14686,7 +14686,7 @@ M: Todor Tomov <[email protected]> L: [email protected] S: Maintained F: Documentation/admin-guide/media/qcom_camss.rst -F: Documentation/devicetree/bindings/media/qcom,camss.txt +F: Documentation/devicetree/bindings/media/*camss* F: drivers/media/platform/qcom/camss/ QUALCOMM CORE POWER REDUCTION (CPR) AVS DRIVER
Signature · 1 line
2.27.0
PATCH v4 19/22 media: dt-bindings: media: Remove qcom,camss documentation
In reply to Robert FossThis documentation has been incorporated in dtschema dt-bindings for the devices supported by CAMSS and is no longer helpful.
--- .../devicetree/bindings/media/qcom,camss.txt | 236 ------------------ 1 file changed, 236 deletions(-) delete mode 100644 Documentation/devicetree/bindings/media/qcom,camss.txt
Documentation/devicetree/bindings/media/qcom,camss.txt deleted +0 -236
@@ -1,236 +0,0 @@ -Qualcomm Camera Subsystem - -* Properties - -- compatible: - Usage: required - Value type: <stringlist> - Definition: Should contain one of: - - "qcom,msm8916-camss" - - "qcom,msm8996-camss" - - "qcom,sdm660-camss" -- reg: - Usage: required - Value type: <prop-encoded-array> - Definition: Register ranges as listed in the reg-names property. -- reg-names: - Usage: required - Value type: <stringlist> - Definition: Should contain the following entries: - - "csiphy0" - - "csiphy0_clk_mux" - - "csiphy1" - - "csiphy1_clk_mux" - - "csiphy2" (8996 only) - - "csiphy2_clk_mux" (8996 only) - - "csid0" - - "csid1" - - "csid2" (8996 only) - - "csid3" (8996 only) - - "ispif" - - "csi_clk_mux" - - "vfe0" - - "vfe1" (8996 only) -- interrupts: - Usage: required - Value type: <prop-encoded-array> - Definition: Interrupts as listed in the interrupt-names property. -- interrupt-names: - Usage: required - Value type: <stringlist> - Definition: Should contain the following entries: - - "csiphy0" - - "csiphy1" - - "csiphy2" (8996 only) - - "csid0" - - "csid1" - - "csid2" (8996 only) - - "csid3" (8996 only) - - "ispif" - - "vfe0" - - "vfe1" (8996 only) -- power-domains: - Usage: required - Value type: <prop-encoded-array> - Definition: A phandle and power domain specifier pairs to the - power domain which is responsible for collapsing - and restoring power to the peripheral. -- clocks: - Usage: required - Value type: <prop-encoded-array> - Definition: A list of phandle and clock specifier pairs as listed - in clock-names property. -- clock-names: - Usage: required - Value type: <stringlist> - Definition: Should contain the following entries: - - "top_ahb" - - "throttle_axi" (660 only) - - "ispif_ahb" - - "csiphy0_timer" - - "csiphy1_timer" - - "csiphy2_timer" (8996 only) - - "csiphy_ahb2crif" (660 only) - - "csi0_ahb" - - "csi0" - - "csi0_phy" - - "csi0_pix" - - "csi0_rdi" - - "cphy_csid0" (660 only) - - "csi1_ahb" - - "csi1" - - "csi1_phy" - - "csi1_pix" - - "csi1_rdi" - - "cphy_csid1" (660 only) - - "csi2_ahb" (8996 only) - - "csi2" (8996 only) - - "csi2_phy" (8996 only) - - "csi2_pix" (8996 only) - - "csi2_rdi" (8996 only) - - "cphy_csid2" (660 only) - - "csi3_ahb" (8996 only) - - "csi3" (8996 only) - - "csi3_phy" (8996 only) - - "csi3_pix" (8996 only) - - "csi3_rdi" (8996 only) - - "cphy_csid3" (660 only) - - "ahb" - - "vfe0" - - "csi_vfe0" - - "vfe0_ahb", (8996 only) - - "vfe0_stream", (8996 only) - - "vfe1", (8996 only) - - "csi_vfe1", (8996 only) - - "vfe1_ahb", (8996 only) - - "vfe1_stream", (8996 only) - - "vfe_ahb" - - "vfe_axi" -- vdda-supply: - Usage: required - Value type: <phandle> - Definition: A phandle to voltage supply for CSI2. -- iommus: - Usage: required - Value type: <prop-encoded-array> - Definition: A list of phandle and IOMMU specifier pairs. - -* Nodes - -- ports: - Usage: required - Definition: As described in video-interfaces.txt in same directory. - Properties: - - reg: - Usage: required - Value type: <u32> - Definition: Selects CSI2 PHY interface - PHY0, PHY1 - or PHY2 (8996 only) - Endpoint node properties: - - clock-lanes: - Usage: required - Value type: <u32> - Definition: The physical clock lane index. On 8916 - the value must always be <1> as the physical - clock lane is lane 1. On 8996 the value must - always be <7> as the hardware supports D-PHY - and C-PHY, indexes are in a common set and - D-PHY physical clock lane is labeled as 7. - - data-lanes: - Usage: required - Value type: <prop-encoded-array> - Definition: An array of physical data lanes indexes. - Position of an entry determines the logical - lane number, while the value of an entry - indicates physical lane index. Lane swapping - is supported. Physical lane indexes for - 8916: 0, 2, 3, 4; for 8996: 0, 1, 2, 3. - -* An Example - - camss: camss@1b00000 { - compatible = "qcom,msm8916-camss"; - reg = <0x1b0ac00 0x200>, - <0x1b00030 0x4>, - <0x1b0b000 0x200>, - <0x1b00038 0x4>, - <0x1b08000 0x100>, - <0x1b08400 0x100>, - <0x1b0a000 0x500>, - <0x1b00020 0x10>, - <0x1b10000 0x1000>; - reg-names = "csiphy0", - "csiphy0_clk_mux", - "csiphy1", - "csiphy1_clk_mux", - "csid0", - "csid1", - "ispif", - "csi_clk_mux", - "vfe0"; - interrupts = <GIC_SPI 78 0>, - <GIC_SPI 79 0>, - <GIC_SPI 51 0>, - <GIC_SPI 52 0>, - <GIC_SPI 55 0>, - <GIC_SPI 57 0>; - interrupt-names = "csiphy0", - "csiphy1", - "csid0", - "csid1", - "ispif", - "vfe0"; - power-domains = <&gcc VFE_GDSC>; - clocks = <&gcc GCC_CAMSS_TOP_AHB_CLK>, - <&gcc GCC_CAMSS_ISPIF_AHB_CLK>, - <&gcc GCC_CAMSS_CSI0PHYTIMER_CLK>, - <&gcc GCC_CAMSS_CSI1PHYTIMER_CLK>, - <&gcc GCC_CAMSS_CSI0_AHB_CLK>, - <&gcc GCC_CAMSS_CSI0_CLK>, - <&gcc GCC_CAMSS_CSI0PHY_CLK>, - <&gcc GCC_CAMSS_CSI0PIX_CLK>, - <&gcc GCC_CAMSS_CSI0RDI_CLK>, - <&gcc GCC_CAMSS_CSI1_AHB_CLK>, - <&gcc GCC_CAMSS_CSI1_CLK>, - <&gcc GCC_CAMSS_CSI1PHY_CLK>, - <&gcc GCC_CAMSS_CSI1PIX_CLK>, - <&gcc GCC_CAMSS_CSI1RDI_CLK>, - <&gcc GCC_CAMSS_AHB_CLK>, - <&gcc GCC_CAMSS_VFE0_CLK>, - <&gcc GCC_CAMSS_CSI_VFE0_CLK>, - <&gcc GCC_CAMSS_VFE_AHB_CLK>, - <&gcc GCC_CAMSS_VFE_AXI_CLK>; - clock-names = "top_ahb", - "ispif_ahb", - "csiphy0_timer", - "csiphy1_timer", - "csi0_ahb", - "csi0", - "csi0_phy", - "csi0_pix", - "csi0_rdi", - "csi1_ahb", - "csi1", - "csi1_phy", - "csi1_pix", - "csi1_rdi", - "ahb", - "vfe0", - "csi_vfe0", - "vfe_ahb", - "vfe_axi"; - vdda-supply = <&pm8916_l2>; - iommus = <&apps_iommu 3>; - ports { - #address-cells = <1>; - #size-cells = <0>; - port@0 { - reg = <0>; - csiphy0_ep: endpoint { - clock-lanes = <1>; - data-lanes = <0 2>; - remote-endpoint = <&ov5645_ep>; - }; - }; - }; - };
Signature · 1 line
2.27.0
Re: [PATCH v4 19/22] media: dt-bindings: media: Remove qcom,camss documentation
Quoted 9 lines · Robert Foss
This documentation has been incorporated in dtschema dt-bindings for the devices supported by CAMSS and is no longer helpful.
Signed-off-by Robert Foss <[email protected]>--- .../devicetree/bindings/media/qcom,camss.txt | 236 ------------------ 1 file changed, 236 deletions(-) delete mode 100644 Documentation/devicetree/bindings/media/qcom,camss.txt
PATCH v4 20/22 arm64: dts: sdm845: Add CAMSS ISP node
In reply to Robert FossAdd the camss dt node for sdm845.
---
Changes since v1
- Laurent: Fix subject
- Laurent: Remove redundant regulator labels
- Laurent: Remove empty line
Changes since v3
- Fixed ordering of IRQs
- Add newlines for better readability
arch/arm64/boot/dts/qcom/sdm845.dtsi | 135 +++++++++++++++++++++++++++ 1 file changed, 135 insertions(+)
arch/arm64/boot/dts/qcom/sdm845.dtsi +135 -0
@@ -3911,6 +3911,141 @@ videocc: clock-controller@ab00000 { #reset-cells = <1>; }; + camss: camss@a00000 { + compatible = "qcom,sdm845-camss"; + + reg = <0 0xacb3000 0 0x1000>, + <0 0xacba000 0 0x1000>, + <0 0xacc8000 0 0x1000>, + <0 0xac65000 0 0x1000>, + <0 0xac66000 0 0x1000>, + <0 0xac67000 0 0x1000>, + <0 0xac68000 0 0x1000>, + <0 0xacaf000 0 0x4000>, + <0 0xacb6000 0 0x4000>, + <0 0xacc4000 0 0x4000>; + reg-names = "csid0", + "csid1", + "csid2", + "csiphy0", + "csiphy1", + "csiphy2", + "csiphy3", + "vfe0", + "vfe1", + "vfe_lite"; + + interrupts = <GIC_SPI 464 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 466 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 468 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 477 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 478 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 479 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 448 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 465 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 467 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 469 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "csid0", + "csid1", + "csid2", + "csiphy0", + "csiphy1", + "csiphy2", + "csiphy3", + "vfe0", + "vfe1", + "vfe_lite"; + + power-domains = <&clock_camcc IFE_0_GDSC>, + <&clock_camcc IFE_1_GDSC>, + <&clock_camcc TITAN_TOP_GDSC>; + + clocks = <&clock_camcc CAM_CC_CAMNOC_AXI_CLK>, + <&clock_camcc CAM_CC_CPAS_AHB_CLK>, + <&clock_camcc CAM_CC_CPHY_RX_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_0_CSID_CLK>, + <&clock_camcc CAM_CC_IFE_0_CSID_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_1_CSID_CLK>, + <&clock_camcc CAM_CC_IFE_1_CSID_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_LITE_CSID_CLK>, + <&clock_camcc CAM_CC_IFE_LITE_CSID_CLK_SRC>, + <&clock_camcc CAM_CC_CSIPHY0_CLK>, + <&clock_camcc CAM_CC_CSI0PHYTIMER_CLK>, + <&clock_camcc CAM_CC_CSI0PHYTIMER_CLK_SRC>, + <&clock_camcc CAM_CC_CSIPHY1_CLK>, + <&clock_camcc CAM_CC_CSI1PHYTIMER_CLK>, + <&clock_camcc CAM_CC_CSI1PHYTIMER_CLK_SRC>, + <&clock_camcc CAM_CC_CSIPHY2_CLK>, + <&clock_camcc CAM_CC_CSI2PHYTIMER_CLK>, + <&clock_camcc CAM_CC_CSI2PHYTIMER_CLK_SRC>, + <&clock_camcc CAM_CC_CSIPHY3_CLK>, + <&clock_camcc CAM_CC_CSI3PHYTIMER_CLK>, + <&clock_camcc CAM_CC_CSI3PHYTIMER_CLK_SRC>, + <&gcc GCC_CAMERA_AHB_CLK>, + <&gcc GCC_CAMERA_AXI_CLK>, + <&clock_camcc CAM_CC_SLOW_AHB_CLK_SRC>, + <&clock_camcc CAM_CC_SOC_AHB_CLK>, + <&clock_camcc CAM_CC_IFE_0_AXI_CLK>, + <&clock_camcc CAM_CC_IFE_0_CLK>, + <&clock_camcc CAM_CC_IFE_0_CPHY_RX_CLK>, + <&clock_camcc CAM_CC_IFE_0_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_1_AXI_CLK>, + <&clock_camcc CAM_CC_IFE_1_CLK>, + <&clock_camcc CAM_CC_IFE_1_CPHY_RX_CLK>, + <&clock_camcc CAM_CC_IFE_1_CLK_SRC>, + <&clock_camcc CAM_CC_IFE_LITE_CLK>, + <&clock_camcc CAM_CC_IFE_LITE_CPHY_RX_CLK>, + <&clock_camcc CAM_CC_IFE_LITE_CLK_SRC>; + clock-names = "camnoc_axi", + "cpas_ahb", + "cphy_rx_src", + "csi0", + "csi0_src", + "csi1", + "csi1_src", + "csi2", + "csi2_src", + "csiphy0", + "csiphy0_timer", + "csiphy0_timer_src", + "csiphy1", + "csiphy1_timer", + "csiphy1_timer_src", + "csiphy2", + "csiphy2_timer", + "csiphy2_timer_src", + "csiphy3", + "csiphy3_timer", + "csiphy3_timer_src", + "gcc_camera_ahb", + "gcc_camera_axi", + "slow_ahb_src", + "soc_ahb", + "vfe0_axi", + "vfe0", + "vfe0_cphy_rx", + "vfe0_src", + "vfe1_axi", + "vfe1", + "vfe1_cphy_rx", + "vfe1_src", + "vfe_lite", + "vfe_lite_cphy_rx", + "vfe_lite_src"; + + iommus = <&apps_smmu 0x0808 0x0>, + <&apps_smmu 0x0810 0x8>, + <&apps_smmu 0x0c08 0x0>, + <&apps_smmu 0x0c10 0x8>; + + status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + }; + }; + cci: cci@ac4a000 { compatible = "qcom,sdm845-cci"; #address-cells = <1>;
Signature · 1 line
2.27.0
PATCH v4 21/22 arm64: dts: sdm845-db845c: Configure regulators for camss node
In reply to Robert FossAdd regulator to camss device tree node.
--- arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-db845c.dts +4 -0
@@ -1106,6 +1106,10 @@ &cci { status = "okay"; }; +&camss { + vdda-supply = <&vreg_l1a_0p875>; +}; + &cci_i2c0 { camera@10 { compatible = "ovti,ov8856";
Signature · 1 line
2.27.0
PATCH v4 22/22 arm64: dts: sdm845-db845c: Enable ov8856 sensor and connect to ISP
In reply to Robert FossEnable camss & ov8856 DT nodes.
--- arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sdm845-db845c.dts +17 -2
@@ -1108,6 +1108,21 @@ &cci { &camss { vdda-supply = <&vreg_l1a_0p875>; + + status = "ok"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + csiphy0_ep: endpoint { + clock-lanes = <1>; + data-lanes = <1 2 3 4>; + remote-endpoint = <&ov8856_ep>; + }; + }; + }; }; &cci_i2c0 {
@@ -1139,7 +1154,7 @@ camera@10 { avdd-supply = <&cam0_avdd_2v8>; dvdd-supply = <&cam0_dvdd_1v2>; - status = "disable"; + status = "ok"; port { ov8856_ep: endpoint {
@@ -1147,7 +1162,7 @@ ov8856_ep: endpoint { link-frequencies = /bits/ 64 <360000000 180000000>; data-lanes = <1 2 3 4>; -// remote-endpoint = <&csiphy0_ep>; + remote-endpoint = <&csiphy0_ep>; }; }; };
Signature · 1 line
2.27.0
Hi Robert,
Quoted 18 lines · Robert Foss
This series implements support for the camera subsystem found in the SDM845 SOCs and the Titan 170 ISP. The support is partial in that it implements CSIPHY, CSID, and partial VFE support.
The Titan generation of the ISP diverges a fair amount from the design of the previous architecture generation, CAMSS. As a result some pretty invasive refactoring is done in this series. It also means that at this time we're unable to implement support for all of the IP blocks contained. This is due to a combination of legal considerations with respect to the IP and its owner Qualcomm and time & man hour constrains on the Linaro side.
The CSIPHY (CSI Physical Layer) & CSID (CSI Decoder) support is complete, but the VFE (Video Front End, which is referred to as IFE (Image Front End) in the Titan generation of ISPs) only has support for the RDI (Raw Dump Interface) which allows the raw output of the CSID to be written to memory.
Quoted 6 lines
The 2nd interface implemented in the VFE silicon is the PIX interface, and camss does not support it for this generation of ISPs. The reason for this is that the PIX interface is used for sending image data to the BPS (Bayer Processing Section) & IPE (Image Processing Engine), but both of these units are beyond the scope of enabling basic ISP functionality for the SDM845.
The problem is that for SDM845 the topology printed by media-ctl still has the PIX devices. That is even though the PIX interface is not supported for SDM845 in this driver, the msm_vfeN_pix subdevices and the corresponding msm_vfeN_video3 devices are still created. Your patchset is currently missing changes to the hardcoded:
#define MSM_VFE_LINE_NUM 4
struct vfe_device {
...
struct vfe_line line[MSM_VFE_LINE_NUM];
...
};
in drivers/media/platform/qcom/camss/camss-vfe.h.
Thanks,
Andrey
Quoted 91 lines
Since the Titan architecture generation diverges quite a bit from the CAMSS generation, a lot of pretty major refactoring is carried out in this series. Both the CSID & VFE core paths are made more general and hardware version specific parts are broken out. The CSIPHY didn't require quite as radical changes and therefore keeps its current form.
Tested on:
- Qcom RB3 / db845c + camera mezzanine, which is SDM845 based
- db410c + D3 Camera mezzanine, which is APQ8016 basedBranch:
- https://git.linaro.org/people/robert.foss/linux.git/log/?h=camss_sdm845_v1
- https://git.linaro.org/people/robert.foss/linux.git/log/?h=camss_sdm845_v2
- https://git.linaro.org/people/robert.foss/linux.git/log/?h=camss_sdm845_v3Due to the dt-bindings supporting sdm660-camss, this series depends the sdm660 clock driver being upstreamed. I've linked this series below.
SDM630/660 Multimedia and GPU clock controllers
https://lkml.org/lkml/2020/9/26/166Robert Foss (22):
media: camss: Fixvfe_isr_comp_done()documentation
media: camss: Fixvfe_isrcomment typo
media: camss: Replacetrace_printk()withdev_dbg()
media: camss: AddCAMSS_845camss version
media: camss: Make ISPIF subdevice optional
media: camss: Refactor VFE HW version support
media: camss: Add support for VFE hardware version Titan 170
media: camss: Add missing format identifiers
media: camss: Refactor CSID HW version support
media: camss: Add support for CSID hardware version Titan 170
media: camss: Add support for CSIPHY hardware version Titan 170
media: camss: Remove per VFE power domain toggling
media: camss: Enable SDM845
dt-bindings: media: camss: Add qcom,msm8916-camss binding
dt-bindings: media: camss: Add qcom,msm8996-camss binding
dt-bindings: media: camss: Add qcom,sdm660-camss binding
dt-bindings: media: camss: Add qcom,sdm845-camss binding
MAINTAINERS: Change CAMSS documentation to use dtschema bindings
media: dt-bindings: media: Remove qcom,camss documentation
arm64: dts: sdm845: Add CAMSS ISP node
arm64: dts: sdm845-db845c: Configure regulators for camss node
arm64: dts: sdm845-db845c: Enable ov8856 sensor and connect to ISP.../devicetree/bindings/media/qcom,camss.txt | 236 ---- .../bindings/media/qcom,msm8916-camss.yaml | 256 ++++ .../bindings/media/qcom,msm8996-camss.yaml | 387 ++++++ .../bindings/media/qcom,sdm660-camss.yaml | 398 ++++++ .../bindings/media/qcom,sdm845-camss.yaml | 370 ++++++ MAINTAINERS | 2 +- arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 23 +- arch/arm64/boot/dts/qcom/sdm845.dtsi | 135 ++ drivers/media/platform/qcom/camss/Makefile | 6 + .../platform/qcom/camss/camss-csid-170.c | 602 +++++++++ .../platform/qcom/camss/camss-csid-4-1.c | 338 +++++ .../platform/qcom/camss/camss-csid-4-7.c | 406 ++++++ .../media/platform/qcom/camss/camss-csid.c | 620 +-------- .../media/platform/qcom/camss/camss-csid.h | 178 ++- .../qcom/camss/camss-csiphy-3ph-1-0.c | 182 ++- .../media/platform/qcom/camss/camss-csiphy.c | 66 +- .../media/platform/qcom/camss/camss-ispif.c | 117 +- .../media/platform/qcom/camss/camss-ispif.h | 3 +- .../media/platform/qcom/camss/camss-vfe-170.c | 804 ++++++++++++ .../media/platform/qcom/camss/camss-vfe-4-1.c | 123 +- .../media/platform/qcom/camss/camss-vfe-4-7.c | 244 ++-- .../media/platform/qcom/camss/camss-vfe-4-8.c | 1164 +++++++++++++++++ .../platform/qcom/camss/camss-vfe-gen1.c | 763 +++++++++++ .../platform/qcom/camss/camss-vfe-gen1.h | 110 ++ drivers/media/platform/qcom/camss/camss-vfe.c | 840 +----------- drivers/media/platform/qcom/camss/camss-vfe.h | 118 +- .../media/platform/qcom/camss/camss-video.c | 100 ++ drivers/media/platform/qcom/camss/camss.c | 419 ++++-- drivers/media/platform/qcom/camss/camss.h | 17 +- 29 files changed, 6965 insertions(+), 2062 deletions(-)delete mode 100644
Documentation/devicetree/bindings/media/qcom,camss.txtcreate mode 100644Documentation/devicetree/bindings/media/qcom,msm8916-camss.yamlcreate mode 100644Documentation/devicetree/bindings/media/qcom,msm8996-camss.yamlcreate mode 100644Documentation/devicetree/bindings/media/qcom,sdm660-camss.yamlcreate mode 100644Documentation/devicetree/bindings/media/qcom,sdm845-camss.yamlcreate mode 100644drivers/media/platform/qcom/camss/camss-csid-170.ccreate mode 100644drivers/media/platform/qcom/camss/camss-csid-4-1.ccreate mode 100644drivers/media/platform/qcom/camss/camss-csid-4-7.ccreate mode 100644drivers/media/platform/qcom/camss/camss-vfe-170.ccreate mode 100644drivers/media/platform/qcom/camss/camss-vfe-4-8.ccreate mode 100644drivers/media/platform/qcom/camss/camss-vfe-gen1.ccreate mode 100644drivers/media/platform/qcom/camss/camss-vfe-gen1.h
Quoted 37 lines · Andrey Konovalov
Hi Robert,
Quoted 18 lines · Robert Foss
This series implements support for the camera subsystem found in the SDM845 SOCs and the Titan 170 ISP. The support is partial in that it implements CSIPHY, CSID, and partial VFE support.
The Titan generation of the ISP diverges a fair amount from the design of the previous architecture generation, CAMSS. As a result some pretty invasive refactoring is done in this series. It also means that at this time we're unable to implement support for all of the IP blocks contained. This is due to a combination of legal considerations with respect to the IP and its owner Qualcomm and time & man hour constrains on the Linaro side.
The CSIPHY (CSI Physical Layer) & CSID (CSI Decoder) support is complete, but the VFE (Video Front End, which is referred to as IFE (Image Front End) in the Titan generation of ISPs) only has support for the RDI (Raw Dump Interface) which allows the raw output of the CSID to be written to memory.
Quoted 6 lines
The 2nd interface implemented in the VFE silicon is the PIX interface, and camss does not support it for this generation of ISPs. The reason for this is that the PIX interface is used for sending image data to the BPS (Bayer Processing Section) & IPE (Image Processing Engine), but both of these units are beyond the scope of enabling basic ISP functionality for the SDM845.
The problem is that for SDM845 the topology printed by media-ctl still has the PIX devices. That is even though the PIX interface is not supported for SDM845 in this driver, the
msm_vfeN_pixsubdevices and the correspondingmsm_vfeN_video3devices are still created. Your patchset is currently missing changes to the hardcoded:#define
MSM_VFE_LINE_NUM4
Quoted 7 lines
struct
vfe_device{
...struct vfe_line line[MSM_VFE_LINE_NUM];...
};in
drivers/media/platform/qcom/camss/camss-vfe.h.
I had a look through the driver and made the line number variable for the different versions of hardware. This required touching most of the vfe related compilation units, but was a pretty mechanical change.
Thanks for spotting this issue.
Quoted 96 lines
Thanks,
AndreyQuoted 91 lines
Since the Titan architecture generation diverges quite a bit from the CAMSS generation, a lot of pretty major refactoring is carried out in this series. Both the CSID & VFE core paths are made more general and hardware version specific parts are broken out. The CSIPHY didn't require quite as radical changes and therefore keeps its current form.
Tested on:
- Qcom RB3 / db845c + camera mezzanine, which is SDM845 based
- db410c + D3 Camera mezzanine, which is APQ8016 basedBranch:
- https://git.linaro.org/people/robert.foss/linux.git/log/?h=camss_sdm845_v1
- https://git.linaro.org/people/robert.foss/linux.git/log/?h=camss_sdm845_v2
- https://git.linaro.org/people/robert.foss/linux.git/log/?h=camss_sdm845_v3Due to the dt-bindings supporting sdm660-camss, this series depends the sdm660 clock driver being upstreamed. I've linked this series below.
SDM630/660 Multimedia and GPU clock controllers
https://lkml.org/lkml/2020/9/26/166Robert Foss (22):
media: camss: Fixvfe_isr_comp_done()documentation
media: camss: Fixvfe_isrcomment typo
media: camss: Replacetrace_printk()withdev_dbg()
media: camss: AddCAMSS_845camss version
media: camss: Make ISPIF subdevice optional
media: camss: Refactor VFE HW version support
media: camss: Add support for VFE hardware version Titan 170
media: camss: Add missing format identifiers
media: camss: Refactor CSID HW version support
media: camss: Add support for CSID hardware version Titan 170
media: camss: Add support for CSIPHY hardware version Titan 170
media: camss: Remove per VFE power domain toggling
media: camss: Enable SDM845
dt-bindings: media: camss: Add qcom,msm8916-camss binding
dt-bindings: media: camss: Add qcom,msm8996-camss binding
dt-bindings: media: camss: Add qcom,sdm660-camss binding
dt-bindings: media: camss: Add qcom,sdm845-camss binding
MAINTAINERS: Change CAMSS documentation to use dtschema bindings
media: dt-bindings: media: Remove qcom,camss documentation
arm64: dts: sdm845: Add CAMSS ISP node
arm64: dts: sdm845-db845c: Configure regulators for camss node
arm64: dts: sdm845-db845c: Enable ov8856 sensor and connect to ISP.../devicetree/bindings/media/qcom,camss.txt | 236 ---- .../bindings/media/qcom,msm8916-camss.yaml | 256 ++++ .../bindings/media/qcom,msm8996-camss.yaml | 387 ++++++ .../bindings/media/qcom,sdm660-camss.yaml | 398 ++++++ .../bindings/media/qcom,sdm845-camss.yaml | 370 ++++++ MAINTAINERS | 2 +- arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 23 +- arch/arm64/boot/dts/qcom/sdm845.dtsi | 135 ++ drivers/media/platform/qcom/camss/Makefile | 6 + .../platform/qcom/camss/camss-csid-170.c | 602 +++++++++ .../platform/qcom/camss/camss-csid-4-1.c | 338 +++++ .../platform/qcom/camss/camss-csid-4-7.c | 406 ++++++ .../media/platform/qcom/camss/camss-csid.c | 620 +-------- .../media/platform/qcom/camss/camss-csid.h | 178 ++- .../qcom/camss/camss-csiphy-3ph-1-0.c | 182 ++- .../media/platform/qcom/camss/camss-csiphy.c | 66 +- .../media/platform/qcom/camss/camss-ispif.c | 117 +- .../media/platform/qcom/camss/camss-ispif.h | 3 +- .../media/platform/qcom/camss/camss-vfe-170.c | 804 ++++++++++++ .../media/platform/qcom/camss/camss-vfe-4-1.c | 123 +- .../media/platform/qcom/camss/camss-vfe-4-7.c | 244 ++-- .../media/platform/qcom/camss/camss-vfe-4-8.c | 1164 +++++++++++++++++ .../platform/qcom/camss/camss-vfe-gen1.c | 763 +++++++++++ .../platform/qcom/camss/camss-vfe-gen1.h | 110 ++ drivers/media/platform/qcom/camss/camss-vfe.c | 840 +----------- drivers/media/platform/qcom/camss/camss-vfe.h | 118 +- .../media/platform/qcom/camss/camss-video.c | 100 ++ drivers/media/platform/qcom/camss/camss.c | 419 ++++-- drivers/media/platform/qcom/camss/camss.h | 17 +- 29 files changed, 6965 insertions(+), 2062 deletions(-)delete mode 100644
Documentation/devicetree/bindings/media/qcom,camss.txtcreate mode 100644Documentation/devicetree/bindings/media/qcom,msm8916-camss.yamlcreate mode 100644Documentation/devicetree/bindings/media/qcom,msm8996-camss.yamlcreate mode 100644Documentation/devicetree/bindings/media/qcom,sdm660-camss.yamlcreate mode 100644Documentation/devicetree/bindings/media/qcom,sdm845-camss.yamlcreate mode 100644drivers/media/platform/qcom/camss/camss-csid-170.ccreate mode 100644drivers/media/platform/qcom/camss/camss-csid-4-1.ccreate mode 100644drivers/media/platform/qcom/camss/camss-csid-4-7.ccreate mode 100644drivers/media/platform/qcom/camss/camss-vfe-170.ccreate mode 100644drivers/media/platform/qcom/camss/camss-vfe-4-8.ccreate mode 100644drivers/media/platform/qcom/camss/camss-vfe-gen1.ccreate mode 100644drivers/media/platform/qcom/camss/camss-vfe-gen1.h