coda988 video codec support
Subsystems (3)
cover coda988 video codec support
Hello!
This is the implementation of the Chips&Media "CODA988" video codec support within v4l2 driver for coda. Support for the following codecs was implemented:
* h264: decoder & encoder * h263: decoder & encoder * mpeg4: decoder & encoder
* vp8dec: decoder
Support for the following formates was implemented:
* yuv420p(I420)
* yvu420p(YV12)
* NV12
* NV21
Also the following features and fixes were implemented for coda988:
* special config for mem_ctrl
* special config for encoder header (sps and pps)
* special set profile_idc
* special set RC config
* special set QP
* special set slice mode
* special set Motion Extimation (ME)
* v4l2_ctrl for h264 profile
* v4l2_ctrl for h264 level
* v4l2_ctrl for h.264 RC mode
* v4l2_ctrl for h.264 skipFrame
* v4l2_ctrl for h.264 i-frame min/max qp
* v4l2_ctrl for h.264 p-frame min/max qp
* v4l2_ctrl for h.264 entropy mode
* v4l2_ctrl for h.264 8x8transform
* v4l2_ctrl for h.264 i-frame period
* v4l2_ctrl for h.264 Access Unit Delimiter(AUD)
* v4l2_ctrl for h.264 me x/y search range
* v4l2_ctrl for h.264 intra refresh period
* v4l2_ctrl for h.263 intra/inter qp
* v4l2_ctrl for h.263 min/max qp
* v4l2_ctrl for mpeg4 min/max qp
During adding support for "CODA988" we also did some extra work related to refactoring and improvement of generic part of C&M coda driver:
* Improve error checking for probe, irq-handle and etc.
* Update work with resets
* Replace hard_irq by threaded_irq
* Remove double setting of stop flag
* Improve some prints
* Fix loglevel to avoid performance failure
* Fix support of MPEG4 levels
* Fix setting gamma for h264enc
* Update default velues of QP for mpeg4 I/P
* Other minor fixes
Sergey Khimich (18):
media: coda: Add print if irq isn't present
media: coda: Use get_array to work use multiple reset
dt-bindings: media: coda: Fix resets count
media: coda: Add check result after reset
media: coda: using threaded_irq for 0 (bit) interrupt
media: coda: Add reset device before getting interrupt
media: coda: Add fake IRQ check
media: coda: Add log to finish_encode if buffer is too small
media: coda: Fix max h.264 level for CODA_DX6
media: coda: Remove double setting of stop flag
media: coda: Print size of encoded buff in other place
media: coda: Fix loglevel for seq mismatch print
media: coda: Fix support for all mpeg4 levels
media: coda: Fix handling wrong format in coda_try_fmt
media: coda: Use v4l2_ctrl to set gamma for h264enc
media: coda: Update default velues of QP for mpeg4 I/P
media: coda: Use preferred usleep_range than udelay
media: coda: add support coda988 enc and dec
.../devicetree/bindings/media/coda.yaml | 2 +- .../platform/chips-media/coda/coda-bit.c | 1114 ++++++++++++++--- .../platform/chips-media/coda/coda-common.c | 430 ++++++- .../platform/chips-media/coda/coda-gdi.c | 149 +++ .../platform/chips-media/coda/coda-h264.c | 10 + .../media/platform/chips-media/coda/coda.h | 41 +- .../platform/chips-media/coda/coda_regs.h | 157 +++ .../media/platform/chips-media/coda/trace.h | 16 + 8 files changed, 1703 insertions(+), 216 deletions(-)
Signature · 1 line
2.30.2
PATCH 1/18 media: coda: Add print if irq isn't present
From: Vladimir Yakovlev <[email protected]>
Use dev_err_probe for print and return error if irq isn't present
--- drivers/media/platform/chips-media/coda/coda-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/chips-media/coda/coda-common.c +1 -1
@@ -3178,7 +3178,7 @@ static int coda_probe(struct platform_device *pdev)if (irq <0 ) irq =platform_get_irq (pdev,0 );if (irq <0 ) -return irq; +return dev_err_probe (&pdev->dev, irq,"Failed to get irq 0 (bit)\n" ); ret =devm_request_irq (&pdev->dev, irq, coda_irq_handler,0 ,CODA_NAME "-video" , dev);
Signature · 1 line
2.30.2
Re: [PATCH 01/18] media: coda: Add print if irq isn't present
Hi,
Le vendredi 14 mars 2025 à 18:29 +0300, Sergey Khimich a écrit :
Quoted 7 lines
From: Vladimir Yakovlev <[email protected]>
Use
dev_err_probefor print and return error if irq isn't presentCo-developed-by Sergey Khimich <[email protected]>Signed-off-by Sergey Khimich <[email protected]>Signed-off-by Vladimir Yakovlev <[email protected]>
Quoted 18 lines
---
drivers/media/platform/chips-media/coda/coda-common.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/chips-media/coda/coda- renamed from drivers/media/platform/chips-media/coda/coda-common.c +0
-0
common.c
index289a076c3bcc..84b9b75b382e100644drivers/media/platform/chips-media/coda/coda-common.c +1
-1@@ -3178,7 +3178,7 @@ static int coda_probe(struct platform_device *pdev) if (irq < 0) irq = platform_get_irq(pdev, 0); if (irq < 0) -return irq; +return dev_err_probe (&pdev->dev, irq,"Failed to get irq 0 (bit)\n" );
ret =devm_request_irq(&pdev->dev, irq, coda_irq_handler, 0, CODA_NAME "-video", dev);
Re: [PATCH 01/18] media: coda: Add print if irq isn't present
Le vendredi 23 mai 2025 à 19:40 -0400, Nicolas Dufresne a écrit :
Quoted 5 lines
Hi,
Le vendredi 14 mars 2025 à 18:29 +0300, Sergey Khimich a écrit :
Quoted 2 lines
From: Vladimir Yakovlev <[email protected]>
Quoted 7 lines
Quoted 5 lines
Use
dev_err_probefor print and return error if irq isn't presentCo-developed-by Sergey Khimich <[email protected]>Signed-off-by Sergey Khimich <[email protected]>Signed-off-by Vladimir Yakovlev <[email protected]>Reviewed-by Nicolas Dufresne <[email protected]>
Please don't forget to move Vladimir SoB first in v2, while adding this Rb. This applies to most of your patches.
Nicolas
Quoted 19 lines
Quoted 19 lines
---
drivers/media/platform/chips-media/coda/coda-common.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/chips-media/coda/coda- renamed from drivers/media/platform/chips-media/coda/coda-common.c +0
-0
common.c
index289a076c3bcc..84b9b75b382e100644drivers/media/platform/chips-media/coda/coda-common.c +1
-1@@ -3178,7 +3178,7 @@ static int coda_probe(struct platform_device *pdev) if (irq < 0) irq = platform_get_irq(pdev, 0); if (irq < 0) -return irq; +return dev_err_probe (&pdev->dev, irq,"Failed to get irq 0 (bit)\n" );
ret =devm_request_irq(&pdev->dev, irq, coda_irq_handler, 0, CODA_NAME "-video", dev);
PATCH 2/18 media: coda: Use get_array to work use multiple reset
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
Some Coda's IP blocks may require more than one reset signal. Than we must use get_array or bulk functions. For compatibility with old code it's better to use devm_reset_control_array_get_optional_exclusive().
--- drivers/media/platform/chips-media/coda/coda-common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/chips-media/coda/coda-common.c +1 -2
@@ -3203,8 +3203,7 @@ static int coda_probe(struct platform_device *pdev) } } - dev->rstc =devm_reset_control_get_optional_exclusive (&pdev->dev, -NULL ); + dev->rstc =devm_reset_control_array_get_optional_exclusive (&pdev->dev);if (IS_ERR (dev->rstc)) { ret =PTR_ERR (dev->rstc);dev_err (&pdev->dev,"failed get reset control: %d\n" , ret);
Signature · 1 line
2.30.2
Re: [PATCH 02/18] media: coda: Use get_array to work use multiple reset
Quoted 9 lines · Sergey Khimich
From: Vladimir Yakovlev <[email protected]>
Some Coda's IP blocks may require more than one reset signal. Than we must use
get_arrayor bulk functions. For compatibility with old code it's better to usedevm_reset_control_array_get_optional_exclusive().Co-developed-by Sergey Khimich <[email protected]>Signed-off-by Sergey Khimich <[email protected]>Signed-off-by Vladimir Yakovlev <[email protected]>
Your chain is supposed to be reverse or fixed other way. Your SoB cannot be before the author. Look at submitting patches - it is explained there pretty precise, exactly your case.
Best regards,
Krzysztof
PATCH 3/18 dt-bindings: media: coda: Fix resets count
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
Change resets count because now we use get array function and reset signas may be more than 1.
--- Documentation/devicetree/bindings/media/coda.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/media/coda.yaml +1 -1
@@ -60,7 +60,7 @@ properties: maxItems: 1 resets: - maxItems: 1 + minItems: 1 iram: $ref: /schemas/types.yaml#/definitions/phandle
Signature · 1 line
2.30.2
Re: [PATCH 03/18] dt-bindings: media: coda: Fix resets count
Quoted 8 lines · Sergey Khimich
From: Vladimir Yakovlev <[email protected]>
Change resets count because now we use get array function and reset signas may be more than 1.
Co-developed-by Sergey Khimich <[email protected]>Signed-off-by Sergey Khimich <[email protected]>Signed-off-by Vladimir Yakovlev <[email protected]>
<form letter>
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.
Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline) or work on fork of kernel (don't, instead use mainline). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.
You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time.
Please kindly resend and include all necessary To/Cc entries. </form letter>
Quoted 9 lines
--- Documentation/devicetree/bindings/media/coda.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Documentation/devicetree/bindings/media/coda.yaml +0
-0
Documentation/devicetree/bindings/media/coda.yaml properties: · line 63
Quoted 5 lines
Documentation/devicetree/bindings/media/coda.yaml +1
-1@@ -60,7 +60,7 @@ properties: maxItems: 1 resets: - maxItems: 1 + minItems: 1
No, this must be specific.
Best regards,
Krzysztof
A message that is not in the archive (sent off-list or not yet received): CABd6DqVZiW4ybyfBi4qgkP7RjRLpaAc4G1n+nBJzTW8fLh3sVQ@mail.gmail.com
Re: [PATCH 03/18] dt-bindings: media: coda: Fix resets count
Quoted 8 lines · Sergey Khimich
Quoted 8 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/media/coda.yamlQuoted 6 lines
index
c9d5adbc8c4a..3cb0e9afc100100644Documentation/devicetree/bindings/media/coda.yaml +0
-0@@ -60,7 +60,7 @@ properties: maxItems: 1
Quoted 8 lines
Quoted 6 lines
Documentation/devicetree/bindings/media/coda.yaml properties: · line 63
Quoted 3 lines
Documentation/devicetree/bindings/media/coda.yaml +1
-1resets: - maxItems: 1 + minItems: 1No, this must be specific.
Here I can suggest the following patch with adding standalone (without a SoC-specific fallback) definition of coda980 codec:
How can it be used outside of soc?
Quoted 11 lines
Documentation/devicetree/bindings/media/coda.yaml +2
-0@@ -30,6 +30,8 @@ properties: - fsl,imx6dl-vpu - fsl,imx6q-vpu - const: cnm,coda960 + - items: + - const: cnm,coda980 reg: maxItems: 1
Documentation/devicetree/bindings/media/coda.yaml properties: · line 65
Quoted 5 lines
Documentation/devicetree/bindings/media/coda.yaml +1
-1@@ -60,7 +62,15 @@ properties: maxItems: 1 resets: - maxItems: 1 + if:
There is no such syntax - see other files or example-schema.
Review properties: · line 71
Quoted 6 lines
(quoted diff) +6
-0+ properties: + compatible: + contains: + const: cnm,coda980 + then: + maxItems: 2 # CODA980 supports 2 resets
Still not specific - you need to list the items. See other files.
Best regards,
Krzysztof
PATCH 4/18 media: coda: Add check result after reset
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
Check result after reset IP block and disable all clocks if return error.
--- drivers/media/platform/chips-media/coda/coda-common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/coda/coda-common.c +5 -1
@@ -2793,7 +2793,9 @@ static int coda_hw_init(struct coda_dev *dev)if (ret) goto err_clk_ahb; -reset_control_reset (dev->rstc); + ret =reset_control_reset (dev->rstc); +if (ret) + goto err_reset;/* * Copy the first CODA_ISRAM_SIZE in the internal SRAM.
@@ -2872,6 +2874,8 @@ static int coda_hw_init(struct coda_dev *dev)return 0 ; +err_reset: +clk_disable_unprepare (dev->clk_ahb); err_clk_ahb:clk_disable_unprepare (dev->clk_per); err_clk_per:
Signature · 1 line
2.30.2
PATCH 5/18 media: coda: using threaded_irq for 0 (bit) interrupt
In reply to Sergey KhimichFrom: Sergey Khimich <[email protected]>
Use threaded_irq for 0 (bit) interrupt instead of lowlevel locked irq.
--- drivers/media/platform/chips-media/coda/coda-common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/chips-media/coda/coda-common.c +4 -2
@@ -3184,8 +3184,10 @@ static int coda_probe(struct platform_device *pdev)if (irq <0 )return dev_err_probe (&pdev->dev, irq,"Failed to get irq 0 (bit)\n" ); - ret =devm_request_irq (&pdev->dev, irq, coda_irq_handler,0 , -CODA_NAME "-video" , dev); + ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , + coda_irq_handler, +IRQF_ONESHOT , +CODA_NAME "-video" , (void *)(dev));if (ret <0 ) {dev_err (&pdev->dev,"failed to request irq: %d\n" , ret);return ret;
Signature · 1 line
2.30.2
Re: [PATCH 05/18] media: coda: using threaded_irq for 0 (bit) interrupt
Hi,
Le vendredi 14 mars 2025 à 18:29 +0300, Sergey Khimich a écrit :
Quoted 3 lines
From: Sergey Khimich <[email protected]>
Use
threaded_irqfor 0 (bit) interrupt instead of lowlevel locked irq.
You omitted a rationale for that, and don't find anything obvious, please drop or defend this change further. Also, Jackson in Wave5/6 actually maintain a hard IRQ for status register handling.
I'd say drop, or explain.
Nicolas
Quoted 24 lines
Signed-off-by Sergey Khimich <[email protected]>---
drivers/media/platform/chips-media/coda/coda-common.c | 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)drivers/media/platform/chips-media/coda/coda- renamed from drivers/media/platform/chips-media/coda/coda-common.c +0
-0
common.c
index64ba17d8adfb..b240091cdc9d100644drivers/media/platform/chips-media/coda/coda-common.c +0
-0@@ -3184,8 +3184,10 @@ static int coda_probe(struct platform_device *pdev) if (irq < 0) return dev_err_probe(&pdev->dev, irq, "Failed to get irq 0 (bit)\n");drivers/media/platform/chips-media/coda/coda-common.c +4
-2- ret =devm_request_irq (&pdev->dev, irq, coda_irq_handler,0 , - CODA_NAME "-video", dev); + ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , + coda_irq_handler, +IRQF_ONESHOT , +CODA_NAME "-video" , (void *)(dev));if (ret < 0) {
dev_err(&pdev->dev, "failed to request irq: %d\n", ret); return ret;
PATCH 6/18 media: coda: Add reset device before getting interrupt
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
Get access to the reset and reset the Coda HW before getting interrupt because sometimes after hot boot(reboot) irq can remain from previous session.
--- .../platform/chips-media/coda/coda-common.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/media/platform/chips-media/coda/coda-common.c +9 -7
@@ -3177,6 +3177,15 @@ static int coda_probe(struct platform_device *pdev)if (IS_ERR (dev->regs_base))return PTR_ERR (dev->regs_base); + dev->rstc =devm_reset_control_array_get_optional_exclusive (&pdev->dev); +if (IS_ERR (dev->rstc)) { + ret =PTR_ERR (dev->rstc); +dev_err (&pdev->dev,"failed get reset control: %d\n" , ret); +return ret; + } + +reset_control_reset (dev->rstc); +/* IRQ */ irq =platform_get_irq_byname (pdev,"bit" );if (irq <0 )
@@ -3209,13 +3218,6 @@ static int coda_probe(struct platform_device *pdev) } } - dev->rstc =devm_reset_control_array_get_optional_exclusive (&pdev->dev); -if (IS_ERR (dev->rstc)) { - ret =PTR_ERR (dev->rstc); -dev_err (&pdev->dev,"failed get reset control: %d\n" , ret); -return ret; - } -/* Get IRAM pool from device tree */ pool =of_gen_pool_get (np,"iram" ,0 );if (!pool) {
Signature · 1 line
2.30.2
PATCH 7/18 media: coda: Add fake IRQ check
In reply to Sergey KhimichFrom: Sergey Khimich <[email protected]>
Sometimes we receive fake interrupts. It's better to check status register and trace fake irq if occurred.
--- .../media/platform/chips-media/coda/coda-bit.c | 16 +++++++++++++++- drivers/media/platform/chips-media/coda/trace.h | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/coda/coda-bit.c +15 -1
@@ -2635,9 +2635,23 @@ irqreturn_t coda_irq_handler(int irq, void *data) {struct coda_dev *dev = data;struct coda_ctx *ctx; +u32 status;/* read status register to attend the IRQ */ -coda_read (dev,CODA_REG_BIT_INT_STATUS ); + status =coda_read (dev,CODA_REG_BIT_INT_STATUS ); +if (!status) { +/* +* Sometimes we received wrong interrupts +* That's why we check status +* and if one of it is zero - wait next interrupts +* You need check your HW configuration +*/ +dev_warn_ratelimited (dev->dev,"Fake irq status=0x%X\n" , + status); +trace_coda_wrong_irq (dev); +return IRQ_HANDLED ; + } +coda_write (dev,0 ,CODA_REG_BIT_INT_REASON );coda_write (dev,CODA_REG_BIT_INT_CLEAR_SET ,CODA_REG_BIT_INT_CLEAR );
drivers/media/platform/chips-media/coda/trace.h +16 -0
@@ -10,6 +10,22 @@#include "coda.h" +TRACE_EVENT (coda_wrong_irq, + TP_PROTO(struct coda_dev *dev), + +TP_ARGS (dev), + +TP_STRUCT__entry ( + __field(struct coda_dev *, dev) + ), + +TP_fast_assign ( + __entry->dev = dev; + ), + +TP_printk (" dev = 0x%p" , __entry->dev) +); + TRACE_EVENT(coda_bit_run, TP_PROTO(struct coda_ctx *ctx, int cmd),
Signature · 1 line
2.30.2
Re: [PATCH 07/18] media: coda: Add fake IRQ check
Hi,
Le vendredi 14 mars 2025 à 18:29 +0300, Sergey Khimich a écrit :
Quoted 25 lines
From: Sergey Khimich <[email protected]>
Sometimes we receive fake interrupts. It's better to check status register and trace fake irq if occurred.
Signed-off-by Sergey Khimich <[email protected]>---
.../media/platform/chips-media/coda/coda-bit.c | 16 +++++++++++++++- drivers/media/platform/chips-media/coda/trace.h | 16 ++++++++++++++++2 files changed, 31 insertions(+), 1 deletion(-)drivers/media/platform/chips-media/coda/coda-bit.c +1
-0@@ -2635,9 +2635,23 @@ irqreturn_t coda_irq_handler(int irq, void *data) { struct coda_dev *dev = data; struct coda_ctx *ctx; +u32 status;
/* read status register to attend the IRQ */drivers/media/platform/chips-media/coda/coda-bit.c +2
-1-coda_read (dev,CODA_REG_BIT_INT_STATUS ); + status =coda_read (dev,CODA_REG_BIT_INT_STATUS ); +if (!status) {
drivers/media/platform/chips-media/coda/coda-bit.c irqreturn_t coda_irq_handler(int irq, void *data) · line 2652
Quoted 10 lines
drivers/media/platform/chips-media/coda/coda-bit.c +10
-0+/* +* Sometimes we received wrong interrupts +* That's why we check status +* and if one of it is zero - wait next interrupts +* You need check your HW configuration +*/ +dev_warn_ratelimited (dev->dev,"Fake irq status=0x%X\n" , + status); +trace_coda_wrong_irq (dev); +return IRQ_HANDLED ;
How often is sometimes ? Does it cause any issues, frame loss ? If not, I would say drop the warning and just swallow it.
Nicolas
Quoted 32 lines
drivers/media/platform/chips-media/coda/coda-bit.c +2
-0+ } +
coda_write(dev, 0, CODA_REG_BIT_INT_REASON);coda_write(dev, CODA_REG_BIT_INT_CLEAR_SET, CODA_REG_BIT_INT_CLEAR);drivers/media/platform/chips-media/coda/trace.h +0
-0@@ -10,6 +10,22 @@
#include "coda.h"drivers/media/platform/chips-media/coda/trace.h +16
-0+TRACE_EVENT (coda_wrong_irq, + TP_PROTO(struct coda_dev *dev), + +TP_ARGS (dev), + +TP_STRUCT__entry ( + __field(struct coda_dev *, dev) + ), + +TP_fast_assign ( + __entry->dev = dev; + ), + +TP_printk (" dev = 0x%p" , __entry->dev) +); +TRACE_EVENT(coda_bit_run,
TP_PROTO(struct coda_ctx *ctx, int cmd),
PATCH 8/18 media: coda: Add log to finish_encode if buffer is too small
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
CODA_RET_ENC_PIC_FLAG flag means that bitstream buffer size is not enough to save one frame data when buffer reset mode is used. If this flag is set, currently encoded bitstream is corrupted.
--- drivers/media/platform/chips-media/coda/coda-bit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/coda/coda-bit.c +7 -1
@@ -1641,6 +1641,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)struct vb2_v4l2_buffer *src_buf, *dst_buf;struct coda_dev *dev = ctx->dev;u32 wr_ptr, start_ptr; +int val;if (ctx->aborting)return ;
@@ -1674,7 +1675,12 @@ static void coda_finish_encode(struct coda_ctx *ctx)coda_dbg (1 , ctx,"frame size = %u\n" , wr_ptr - start_ptr);coda_read (dev,CODA_RET_ENC_PIC_SLICE_NUM ); -coda_read (dev,CODA_RET_ENC_PIC_FLAG ); + val =coda_read (dev,CODA_RET_ENC_PIC_FLAG ); +if (val >0 ) { +v4l2_err (&dev->v4l2_dev, +"Encode fail. Encode buffer is too small\n" ); +// TODO what to do next? + } dst_buf->flags &= ~(V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_PFRAME |
Signature · 1 line
2.30.2
Re: [PATCH 08/18] media: coda: Add log to finish_encode if buffer is too small
Hi,
Le vendredi 14 mars 2025 à 18:29 +0300, Sergey Khimich a écrit :
Quoted 29 lines
From: Vladimir Yakovlev <[email protected]>
CODA_RET_ENC_PIC_FLAGflag means that bitstream buffer size is not enough to save one frame data when buffer reset mode is used. If this flag is set, currently encoded bitstream is corrupted.Co-developed-by Sergey Khimich <[email protected]>Signed-off-by Sergey Khimich <[email protected]>Signed-off-by Vladimir Yakovlev <[email protected]>---
drivers/media/platform/chips-media/coda/coda-bit.c | 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)drivers/media/platform/chips-media/coda/coda-bit.c +1
-0@@ -1641,6 +1641,7 @@ static void coda_finish_encode(struct coda_ctx *ctx) struct vb2_v4l2_buffer *src_buf, *dst_buf; struct coda_dev *dev = ctx->dev; u32 wr_ptr, start_ptr; +int val;
if (ctx->aborting)
return;drivers/media/platform/chips-media/coda/coda-bit.c +0
-0@@ -1674,7 +1675,12 @@ static void coda_finish_encode(struct coda_ctx *ctx) coda_dbg(1, ctx, "frame size = %u\n", wr_ptr - start_ptr);
coda_read(dev, CODA_RET_ENC_PIC_SLICE_NUM);
drivers/media/platform/chips-media/coda/coda-bit.c static void coda_finish_encode(struct coda_ctx *ctx) · line 1682
Quoted 6 lines
drivers/media/platform/chips-media/coda/coda-bit.c +5
-1-coda_read (dev,CODA_RET_ENC_PIC_FLAG ); + val =coda_read (dev,CODA_RET_ENC_PIC_FLAG ); +if (val >0 ) { +v4l2_err (&dev->v4l2_dev, +"Encode fail. Encode buffer is too small\n" ); +// TODO what to do next?
Lower in the same function, you should still copy the metadata but replace VB2_BUF_STATE_DONE with VB2_BUF_STATE_ERROR. Perhaps introduce a state variable and set it accordingly.
Nicolas
Quoted 4 lines
drivers/media/platform/chips-media/coda/coda-bit.c +1
-0+ }
dst_buf->flags&= ~(V4L2_BUF_FLAG_KEYFRAME |V4L2_BUF_FLAG_PFRAME|
PATCH 9/18 media: coda: Fix max h.264 level for CODA_DX6
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
CODA_DX6 has h.264 decoder but v4l2_ctrls of level wasn't setting for this device.
--- drivers/media/platform/chips-media/coda/coda-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/chips-media/coda/coda-common.c +2 -2
@@ -2440,8 +2440,8 @@ static void coda_decode_ctrls(struct coda_ctx *ctx) max =V4L2_MPEG_VIDEO_H264_LEVEL_4_0 ; else if (ctx->dev->devtype->product == CODA_960) max =V4L2_MPEG_VIDEO_H264_LEVEL_4_1 ; - else - return; + else /* CODA_DX6 */ + max =V4L2_MPEG_VIDEO_H264_LEVEL_3_0 ; ctx->h264_level_ctrl =v4l2_ctrl_new_std_menu (&ctx->ctrls, &coda_ctrl_ops,V4L2_CID_MPEG_VIDEO_H264_LEVEL , max,0 , max);if (ctx->h264_level_ctrl)
Signature · 1 line
2.30.2
Re: [PATCH 09/18] media: coda: Fix max h.264 level for CODA_DX6
Hi,
Le vendredi 14 mars 2025 à 18:29 +0300, Sergey Khimich a écrit :
Quoted 3 lines
From: Vladimir Yakovlev <[email protected]>
CODA_DX6has h.264 decoder butv4l2_ctrlsof level wasn't setting
Perhaps:CODA_DX6 supports H.264 decoder, though the maximum level wasn't set properly.
regards,
Nicolas
Quoted 26 lines
for this device.
Co-developed-by Sergey Khimich <[email protected]>Signed-off-by Sergey Khimich <[email protected]>Signed-off-by Vladimir Yakovlev <[email protected]>---
drivers/media/platform/chips-media/coda/coda-common.c | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/media/platform/chips-media/coda/coda- renamed from drivers/media/platform/chips-media/coda/coda-common.c +0
-0
common.c
index33c7e8398f31..555b73816952100644drivers/media/platform/chips-media/coda/coda-common.c +2
-2@@ -2440,8 +2440,8 @@ static void coda_decode_ctrls(struct coda_ctx *ctx) max = V4L2_MPEG_VIDEO_H264_LEVEL_4_0; else if (ctx->dev->devtype->product == CODA_960) max = V4L2_MPEG_VIDEO_H264_LEVEL_4_1; -else -return ; +else /* CODA_DX6 */ + max =V4L2_MPEG_VIDEO_H264_LEVEL_3_0 ; ctx->h264_level_ctrl = v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops, V4L2_CID_MPEG_VIDEO_H264_LEVEL, max, 0, max); if (ctx->h264_level_ctrl)
PATCH 10/18 media: coda: Remove double setting of stop flag
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
Remove double setting flag 'CODA_BIT_STREAM_END_FLAG' and corresponding write to the coda's register. The flag is already set when system calls v4l2 function stop_streaming()->..-<coda_bit_stream_end_flag(). And this was the second write of this flag.
--- drivers/media/platform/chips-media/coda/coda-bit.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/media/platform/chips-media/coda/coda-bit.c +0 -7
@@ -1611,13 +1611,6 @@ static int coda_prepare_encode(struct coda_ctx *ctx)coda_write (dev, pic_stream_buffer_size /1024 ,CODA_CMD_ENC_PIC_BB_SIZE ); -if (!ctx->streamon_out) { -/* After streamoff on the output side, set stream end flag */ - ctx->bit_stream_param |=CODA_BIT_STREAM_END_FLAG ; -coda_write (dev, ctx->bit_stream_param, -CODA_REG_BIT_BIT_STREAM_PARAM ); - } -if (dev->devtype->product !=CODA_DX6 )coda_write (dev, ctx->iram_info.axi_sram_use,CODA7_REG_BIT_AXI_SRAM_USE );
Signature · 1 line
2.30.2
PATCH 11/18 media: coda: Print size of encoded buff in other place
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
Print debug log containing size of encoded buff along with other info of encoded buffer. This improves readability of the log.
--- drivers/media/platform/chips-media/coda/coda-bit.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/platform/chips-media/coda/coda-bit.c +2 -3
@@ -1665,7 +1665,6 @@ static void coda_finish_encode(struct coda_ctx *ctx)vb2_set_plane_payload (&dst_buf->vb2_buf,0 , wr_ptr - start_ptr); } -coda_dbg (1 , ctx,"frame size = %u\n" , wr_ptr - start_ptr);coda_read (dev,CODA_RET_ENC_PIC_SLICE_NUM ); val =coda_read (dev,CODA_RET_ENC_PIC_FLAG );
@@ -1696,9 +1695,9 @@ static void coda_finish_encode(struct coda_ctx *ctx)if (ctx->gopcounter <0 ) ctx->gopcounter = ctx->params.gop_size -1 ; -coda_dbg (1 , ctx,"job finished: encoded %c frame (%d)%s\n" , +coda_dbg (1 , ctx,"job finished: encoded %c frame (%d)%s size=%d\n" ,coda_frame_type_char (dst_buf->flags), dst_buf->sequence, - (dst_buf->flags &V4L2_BUF_FLAG_LAST ) ?" (last)" :"" ); + (dst_buf->flags &V4L2_BUF_FLAG_LAST ) ?" (last)" :"" , wr_ptr - start_ptr); }static void coda_seq_end_work (struct work_struct *work)
Signature · 1 line
2.30.2
PATCH 12/18 media: coda: Fix loglevel for seq mismatch print
In reply to Sergey KhimichFrom: Sergey Khimich <[email protected]>
During decoding process some files (conceivably with max_dec_frame_buffering == 16) a situation may arise, in which after getting 'DEC_PIC_RUN' interrupt we have "-1" in 'CODA_RET_DEC_PIC_CUR_IDX' register. In such case it means that current picture has been decoded but there is no frame buffer to store the decoded picture (this is a kind of error situation). The documentation says that in such situation we have to rerun decoding the frame.
On the other hand in the driver such situation leads to sequence number discrepancy whish in general is not good. Also for every discrepancy we get error message. But in real user scenarios (playing video) there is no any errors caused by this sequence number discrepancy.
Althogh there is no real errors, lots of "error" messages, in turn, lead to decreasing fps and dropping frames in user space utils, e.g. in Gstreamer.
The following Gstreamer log is obtained _without_ this patch:
last-message = rendered: 17, dropped: 0, current: 33.76, average: 33.76 last-message = rendered: 33, dropped: 0, current: 30.01, average: 31.83 last-message = rendered: 49, dropped: 0, current: 30.01, average: 31.21 last-message = rendered: 65, dropped: 0, current: 30.00, average: 30.90 last-message = rendered: 81, dropped: 0, current: 30.00, average: 30.72 last-message = rendered: 97, dropped: 0, current: 30.00, average: 30.60 last-message = rendered: 112, dropped: 0, current: 30.00, average: 30.52 last-message = rendered: 127, dropped: 0, current: 30.00, average: 30.46 last-message = rendered: 142, dropped: 0, current: 30.00, average: 30.41 last-message = rendered: 157, dropped: 0, current: 30.00, average: 30.37 last-message = rendered: 173, dropped: 0, current: 30.00, average: 30.33 last-message = rendered: 189, dropped: 0, current: 30.00, average: 30.30 last-message = rendered: 205, dropped: 0, current: 30.00, average: 30.28 last-message = rendered: 220, dropped: 0, current: 30.00, average: 30.26 last-message = rendered: 236, dropped: 0, current: 30.00, average: 30.24 last-message = rendered: 251, dropped: 0, current: 24.84, average: 29.86 last-message = rendered: 264, dropped: 1, fps: 24.55, drop rate: 1.89 last-message = rendered: 279, dropped: 1, current: 30.00, average: 29.57
The next log is obtained _with_ this patch:
last-message = rendered: 17, dropped: 0, current: 33.76, average: 33.76 last-message = rendered: 33, dropped: 0, current: 30.03, average: 31.84 last-message = rendered: 49, dropped: 0, current: 30.01, average: 31.22 last-message = rendered: 65, dropped: 0, current: 30.00, average: 30.91 last-message = rendered: 80, dropped: 0, current: 30.00, average: 30.73 last-message = rendered: 96, dropped: 0, current: 30.00, average: 30.61 last-message = rendered: 112, dropped: 0, current: 30.00, average: 30.52 last-message = rendered: 128, dropped: 0, current: 30.00, average: 30.46 last-message = rendered: 144, dropped: 0, current: 30.00, average: 30.40 last-message = rendered: 160, dropped: 0, current: 30.00, average: 30.36 last-message = rendered: 175, dropped: 0, current: 30.00, average: 30.33 last-message = rendered: 191, dropped: 0, current: 30.00, average: 30.30 last-message = rendered: 207, dropped: 0, current: 30.00, average: 30.28 last-message = rendered: 223, dropped: 0, current: 30.00, average: 30.26 last-message = rendered: 239, dropped: 0, current: 30.01, average: 30.24 last-message = rendered: 254, dropped: 0, current: 30.00, average: 30.23 last-message = rendered: 269, dropped: 0, current: 30.00, average: 30.22 last-message = rendered: 285, dropped: 0, current: 30.00, average: 30.20
So it is better to lower the message priority.
--- drivers/media/platform/chips-media/coda/coda-bit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/platform/chips-media/coda/coda-bit.c +4 -4
@@ -2466,10 +2466,10 @@ static void coda_finish_decode(struct coda_ctx *ctx)* from doing different things based on the format. */ if ((sequence &0xffff ) != (meta->sequence &0xffff )) { -v4l2_err (&dev->v4l2_dev, -"sequence number mismatch (%d(%d) != %d)\n" , - sequence, ctx->sequence_offset, - meta->sequence); +v4l2_warn (&dev->v4l2_dev, +"sequence number mismatch (%d(%d) != %d)\n" , + sequence, ctx->sequence_offset, + meta->sequence); } decoded_frame->meta = *meta;kfree (meta);
Signature · 1 line
2.30.2
PATCH 13/18 media: coda: Fix support for all mpeg4 levels
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
Mpeg-4 level also depends on img resolution.
Therefore, driver must support all levels in the range of supported resolutions. Coda's hw can calculate level automatically.
--- drivers/media/platform/chips-media/coda/coda-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/chips-media/coda/coda-common.c +1 -1
@@ -2383,7 +2383,7 @@ static void coda_encode_ctrls(struct coda_ctx *ctx)v4l2_ctrl_new_std_menu (&ctx->ctrls, &coda_ctrl_ops,V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL ,V4L2_MPEG_VIDEO_MPEG4_LEVEL_5 , - ~(1 <<V4L2_MPEG_VIDEO_MPEG4_LEVEL_5 ), +0 ,V4L2_MPEG_VIDEO_MPEG4_LEVEL_5 ); } v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops,
Signature · 1 line
2.30.2
PATCH 14/18 media: coda: Fix handling wrong format in coda_try_fmt
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
No need to print BUG() report when received wrong format in coda_try_fmt. It's enough to print log and return an error.
--- drivers/media/platform/chips-media/coda/coda-common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/coda/coda-common.c +3 -1
@@ -644,7 +644,9 @@ static int coda_try_fmt(struct coda_ctx *ctx, const struct coda_codec *codec, f->fmt.pix.height);break ;default : -BUG (); +v4l2_warn (&dev->v4l2_dev,"Warning: wrong format=0x%04X" , + f->fmt.pix.pixelformat); +return -EINVAL ; }return 0 ;
Signature · 1 line
2.30.2
PATCH 15/18 media: coda: Use v4l2_ctrl to set gamma for h264enc
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
We can use v4l2_ctrl (V4L2_CID_GAMMA) to set gamma for configuration h.264 encoder.
--- .../platform/chips-media/coda/coda-bit.c | 28 ++++++------------- .../platform/chips-media/coda/coda-common.c | 7 +++++ .../media/platform/chips-media/coda/coda.h | 4 +++ 3 files changed, 20 insertions(+), 19 deletions(-)
drivers/media/platform/chips-media/coda/coda-bit.c +9 -19
@@ -35,9 +35,6 @@#define CODA7_PS_BUF_SIZE 0x28000#define CODA9_PS_SAVE_SIZE (512 * 1024) -#define CODA_DEFAULT_GAMMA 4096 -#define CODA9_DEFAULT_GAMMA 24576/* 0.75 * 32768 */ -static void coda_free_bitstream_buffer (struct coda_ctx *ctx);static inline int coda_is_initialized (struct coda_dev *dev)
@@ -1065,7 +1062,7 @@ static int coda_start_encoding(struct coda_ctx *ctx)struct coda_q_data *q_data_src, *q_data_dst;u32 bitstream_buf, bitstream_size;struct vb2_v4l2_buffer *buf; -int gamma, ret, value; +int ret, value;u32 dst_fourcc;int num_fb;u32 stride;
@@ -1251,13 +1248,14 @@ static int coda_start_encoding(struct coda_ctx *ctx) value =0 ; -if (dev->devtype->product ==CODA_960 ) - gamma =CODA9_DEFAULT_GAMMA ; -else - gamma =CODA_DEFAULT_GAMMA ; -if (gamma >0 ) { -coda_write (dev, (gamma &CODA_GAMMA_MASK ) <<CODA_GAMMA_OFFSET , -CODA_CMD_ENC_SEQ_RC_GAMMA ); +if (ctx->params.gamma >0 ) { +if (dev->devtype->product ==CODA_960 ) + value |=1 <<CODA9_OPTION_GAMMA_OFFSET ; +else if (dev->devtype->product ==CODA_DX6 ) + value |=1 <<CODADX6_OPTION_GAMMA_OFFSET ; +else + value |=1 <<CODA7_OPTION_GAMMA_OFFSET ; +coda_write (dev, ctx->params.gamma,CODA_CMD_ENC_SEQ_RC_GAMMA ); }if (ctx->params.h264_min_qp || ctx->params.h264_max_qp) {
@@ -1269,15 +1267,7 @@ static int coda_start_encoding(struct coda_ctx *ctx)if (dev->devtype->product ==CODA_960 ) {if (ctx->params.h264_max_qp) value |=1 <<CODA9_OPTION_RCQPMAX_OFFSET ; -if (CODA_DEFAULT_GAMMA >0 ) - value |=1 <<CODA9_OPTION_GAMMA_OFFSET ; }else { -if (CODA_DEFAULT_GAMMA >0 ) { -if (dev->devtype->product ==CODA_DX6 ) - value |=1 <<CODADX6_OPTION_GAMMA_OFFSET ; -else - value |=1 <<CODA7_OPTION_GAMMA_OFFSET ; - }if (ctx->params.h264_min_qp) value |=1 <<CODA7_OPTION_RCQPMIN_OFFSET ;if (ctx->params.h264_max_qp)
drivers/media/platform/chips-media/coda/coda-common.c +7 -0
@@ -2205,6 +2205,9 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl) ctx->params.bitrate = ctrl->val /1000 ; ctx->params.bitrate_changed = true;break ; +case V4L2_CID_GAMMA : + ctx->params.gamma = ctrl->val; +break ;case V4L2_CID_MPEG_VIDEO_GOP_SIZE : ctx->params.gop_size = ctrl->val;break ;
@@ -2311,9 +2314,13 @@ static const struct v4l2_ctrl_ops coda_ctrl_ops = {static void coda_encode_ctrls (struct coda_ctx *ctx) {int max_gop_size = (ctx->dev->devtype->product ==CODA_DX6 ) ?60 :99 ; +u32 def_gamma = (ctx->dev->devtype->product ==CODA_960 ) ? +CODA9_DEFAULT_GAMMA :CODA_DEFAULT_GAMMA ;v4l2_ctrl_new_std (&ctx->ctrls, &coda_ctrl_ops,V4L2_CID_MPEG_VIDEO_BITRATE ,0 ,32767000 ,1000 ,0 ); +v4l2_ctrl_new_std (&ctx->ctrls, &coda_ctrl_ops, +V4L2_CID_GAMMA ,0 ,0x7FFFFFFF ,1 , def_gamma);v4l2_ctrl_new_std (&ctx->ctrls, &coda_ctrl_ops,V4L2_CID_MPEG_VIDEO_GOP_SIZE ,0 , max_gop_size,1 ,16 ); v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
drivers/media/platform/chips-media/coda/coda.h +4 -0
@@ -29,6 +29,9 @@#define CODA_MAX_FRAMEBUFFERS 19#define FMO_SLICE_SAVE_BUF_SIZE (32) +#define CODA_DEFAULT_GAMMA 4096 +#define CODA9_DEFAULT_GAMMA 24576/* 0.75 * 32768 */ +/* * This control allows applications to read the per-stream * (i.e. per-context) Macroblocks Error Count. This value
@@ -150,6 +153,7 @@ struct coda_params {u32 vbv_size;u32 slice_max_bits;u32 slice_max_mb; +u32 gamma;bool force_ipicture;bool gop_size_changed;bool bitrate_changed;
Signature · 1 line
2.30.2
PATCH 16/18 media: coda: Update default velues of QP for mpeg4 I/P
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
Use average values of QP range for mpeg4 I/P frames. In such case we get smaller size of output buffer and average quality of image.
--- drivers/media/platform/chips-media/coda/coda-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/chips-media/coda/coda-common.c +2 -2
@@ -2379,9 +2379,9 @@ static void coda_encode_ctrls(struct coda_ctx *ctx) V4L2_MPEG_VIDEO_H264_LEVEL_4_0); }v4l2_ctrl_new_std (&ctx->ctrls, &coda_ctrl_ops, -V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP ,1 ,31 ,1 ,2 ); +V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP ,1 ,31 ,1 ,15 );v4l2_ctrl_new_std (&ctx->ctrls, &coda_ctrl_ops, -V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP ,1 ,31 ,1 ,2 ); +V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP ,1 ,31 ,1 ,15 ); v4l2_ctrl_new_std_menu(&ctx->ctrls, &coda_ctrl_ops, V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE, V4L2_MPEG_VIDEO_MPEG4_PROFILE_SIMPLE, 0x0,
Signature · 1 line
2.30.2
PATCH 17/18 media: coda: Use preferred usleep_range than udelay
In reply to Sergey KhimichFrom: Vladimir Yakovlev <[email protected]>
usleep_range is preferred over udelay.
see Documentation/timers/timers-howto.rst
--- drivers/media/platform/chips-media/coda/coda-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/chips-media/coda/coda-common.c +1 -1
@@ -2873,7 +2873,7 @@ static int coda_hw_init(struct coda_dev *dev) data =coda_read (dev,CODA_REG_BIT_CODE_RESET ); data |=CODA_REG_RESET_ENABLE ;coda_write (dev, data,CODA_REG_BIT_CODE_RESET ); -udelay (10 ); +usleep_range (10 ,20 ); data &= ~CODA_REG_RESET_ENABLE ;coda_write (dev, data,CODA_REG_BIT_CODE_RESET );coda_write (dev,CODA_REG_RUN_ENABLE ,CODA_REG_BIT_CODE_RUN );
Signature · 1 line
2.30.2
PATCH 18/18 media: coda: add support coda988 enc and dec
In reply to Sergey KhimichFrom: Sergey Khimich <[email protected]>
Implemet support for Chips&Media coda988 encoder & decoder.
support codecs h264enc/dec, h263enc/dec mpeg4enc/dec vp8dec support formats yuv420p(I420), yvu420p(YV12), NV12, NV21 special config for mem_ctrl
special config for encoder header (sps and pps) special set profile_idc
special set RC config
special set QP
special set slice mode
special set Motion Extimation (ME)
new v4l2_ctrls:
update coda988's v4l2_ctrl for h264 profile
update coda988's v4l2_ctrl for h264 level
add coda988's v4l2_ctrl for h.264 RC mode
add coda988's v4l2_ctrl for h.264 skipFrame
add coda988's v4l2_ctrl for h.264 i-frame min/max qp add coda988's v4l2_ctrl for h.264 p-frame min/max qp add coda988's v4l2_ctrl for h.264 entropy mode
add coda988's v4l2_ctrl for h.264 8x8transform
add coda988's v4l2_ctrl for h.264 i-frame period add coda988's v4l2_ctrl for h.264 Access Unit Delimiter(AUD) add coda988's v4l2_ctrl for h.264 me x/y search range add coda988's v4l2_ctrl for h.264 intra refresh period add coda988's v4l2_ctrl for h.263 intra/inter qp add coda988's v4l2_ctrl for h.263 min/max qp
add coda988's v4l2_ctrl for mpeg4 min/max qp
--- .../platform/chips-media/coda/coda-bit.c | 1046 ++++++++++++++--- .../platform/chips-media/coda/coda-common.c | 382 +++++- .../platform/chips-media/coda/coda-gdi.c | 149 +++ .../platform/chips-media/coda/coda-h264.c | 10 + .../media/platform/chips-media/coda/coda.h | 37 +- .../platform/chips-media/coda/coda_regs.h | 157 +++ 6 files changed, 1615 insertions(+), 166 deletions(-)
drivers/media/platform/chips-media/coda/coda-bit.c +913 -133
@@ -15,6 +15,7 @@#include <linux/platform_device.h> #include <linux/ratelimit.h> #include <linux/reset.h> +#include <linux/sched.h> #include <linux/slab.h> #include <linux/videodev2.h>
@@ -35,6 +36,49 @@#define CODA7_PS_BUF_SIZE 0x28000#define CODA9_PS_SAVE_SIZE (512 * 1024) +/* +* For CODA988: +* In the parameter buffer, following sorts of buffer addresses +* are internally stored from their byte offset: +* 0-383: adressses of frame buffers +* 384-511: addresses of mv colocated buffers +* 512-895: bottom addresses of frambuffers (when tiled map is used) +* 896-1279: top address of WTL frame buffer (when WTL function is enabled) +* 1280: bottom address of WTL frame buffer (when WTL function is enabled) +*/ +#define CODA988_MVC_BYTE_OFFSET 384 +#define CODA988_FB_BOT_BYTE_OFFSET (CODA988_MVC_BYTE_OFFSET + 128) +#define CODA988_WTL_FB_TOP_BYTE_OFFSET (CODA988_FB_BOT_BYTE_OFFSET + 384) +#define CODA988_WTL_FB_BOT_BYTE_OFFSET (CODA988_WTL_FB_TOP_BYTE_OFFSET + 384) + +/* Advanced INTRA Coding mode. */ +#define CODA988_H263_ANNEX_I_ENABLE 0 +/* Deblocking Filter mode */ +#define CODA988_H263_ANNEX_J_ENABLE 0 +/* Slice Structured mode */ +#define CODA988_H263_ANNEX_K_ENABLE 0 +/* Modified Quantization mode */ +#define CODA988_H263_ANNEX_T_ENABLE 0 + +/* MPEG-4 Data Partition */ +#define CODA988_MP4_INTRA_DC_VLC_THR 0 +/* MPEG-4 VLC table used 0-normal / 1-reversible */ +#define CODA988_MP4_REVERSIBLE_VLC_EN 0 +/* MPEG-4 Intra DC VLC Threshold [0~7] */ +#define CODA988_MP4_DATA_PARTITION_EN 0 +/* MPEG-4 Enable Header Extension Code (HEC) */ +#define CODA988_MP4_HEC_EN 1 +/* MPEG-4 Video Object layer version 1 or 2(default) */ +#define CODA988_MP4_VER_ID 2 + +/* sps[64], pps[256], backupPsBuf[8] for rollback, error concealment (each 4Kbyte) */ +#define CODA988_PS_SAVE_SIZE ((320 + 8) * 1024 * 4) + +#define CODA_988_CROP_SHIFT 16 +#define CODA_988_CROP_MASK 0xFFFF +#define CODA_COMMON_CROP_SHIFT 10 +#define CODA_COMMON_CROP_MASK 0x3FFF +static void coda_free_bitstream_buffer (struct coda_ctx *ctx);static inline int coda_is_initialized (struct coda_dev *dev)
@@ -42,18 +86,21 @@ static inline int coda_is_initialized(struct coda_dev *dev)return coda_read (dev,CODA_REG_BIT_CUR_PC ) !=0 ; } -static inline unsigned long coda_isbusy (struct coda_dev *dev) +static inline unsigned long coda_isbusy (struct coda_dev *dev,u32 reg_busy) { -return coda_read (dev,CODA_REG_BIT_BUSY ); +return coda_read (dev, reg_busy); } -static int coda_wait_timeout (struct coda_dev *dev) +int coda_wait_timeout (struct coda_dev *dev,u32 reg_busy) {unsigned long timeout = jiffies +msecs_to_jiffies (1000 ); -while (coda_isbusy (dev)) { -if (time_after (jiffies, timeout)) +while (coda_isbusy (dev, reg_busy)) { +if (time_after (jiffies, timeout)) { +dev_err (dev->dev,"Error! Timeout waiting for reg 0x%x\n" , + reg_busy);return -ETIMEDOUT ; + } }return 0 ; }
@@ -64,7 +111,8 @@ static void coda_command_async(struct coda_ctx *ctx, int cmd)if (dev->devtype->product ==CODA_HX4 || dev->devtype->product ==CODA_7541 || - dev->devtype->product ==CODA_960 ) { + dev->devtype->product ==CODA_960 || + dev->devtype->product ==CODA_988 ) {/* Restore context related registers to CODA */ coda_write (dev, ctx->bit_stream_param,CODA_REG_BIT_BIT_STREAM_PARAM );
@@ -75,7 +123,8 @@ static void coda_command_async(struct coda_ctx *ctx, int cmd)coda_write (dev, ctx->workbuf.paddr,CODA_REG_BIT_WORK_BUF_ADDR ); } -if (dev->devtype->product ==CODA_960 ) { +if (dev->devtype->product ==CODA_960 || + dev->devtype->product ==CODA_988 ) {coda_write (dev,1 ,CODA9_GDI_WPROT_ERR_CLR );coda_write (dev,0 ,CODA9_GDI_WPROT_RGN_EN ); }
@@ -99,12 +148,132 @@ static int coda_command_sync(struct coda_ctx *ctx, int cmd)lockdep_assert_held (&dev->coda_mutex);coda_command_async (ctx, cmd); - ret =coda_wait_timeout (dev); + ret =coda_wait_timeout (dev,CODA_REG_BIT_BUSY );trace_coda_bit_done (ctx);return ret; } +int coda988_hw_init_reset (struct coda_dev *dev) +{ +unsigned long timeout; +u32 reg, ret =0 ; + +/* Waiting for completion of BWB transaction first */ +if (coda_wait_timeout (dev,CODA9_GDI_BWB_STATUS )) { +dev_err (dev->dev,"Error! Timeout waiting for completion of BWB transaction\n" ); +return -ETIME ; + } + +/* No more requests */ +coda_write (dev,0x11 ,CODA9_GDI_BUS_CTRL ); +/* Waiting for completion of bus transaction */ + timeout = jiffies +msecs_to_jiffies (100 ); +while (coda_read (dev,CODA9_GDI_BUS_STATUS ) !=0x77 ) { +if (time_after (jiffies, timeout)) { +coda_write (dev,0x0 ,CODA9_GDI_BUS_CTRL ); +dev_err (dev->dev,"Error! Timeout waiting for completion of BUS transaction\n" ); +return -ETIME ; + } +cpu_relax (); + } + +/* Software Reset Trigger */ + reg =CODA9_SW_RESET_VCE_CORE |CODA9_SW_RESET_VCE_BUS | +CODA9_SW_RESET_GDI_CORE |CODA9_SW_RESET_GDI_BUS ; + +dev_dbg (dev->dev,"ATTENTION! Resetting GDI: tiled map should be reconfigured\n" ); + +coda_write (dev, reg,CODA9_REG_BIT_SW_RESET ); + +/* Wait until reset is done */ +if (coda_wait_timeout (dev,CODA9_REG_BIT_SW_RESET_STATUS )) { +dev_err (dev->dev,"Error! Timeout waiting for completion of SW reset\n" ); + ret = -ETIME ; + } + +coda_write (dev,0x0 ,CODA9_REG_BIT_SW_RESET ); +coda_write (dev,0x0 ,CODA9_GDI_BUS_CTRL ); + +return ret; +} + +static int coda988_hw_runtime_reset (struct coda_ctx *ctx) +{ +struct coda_dev *dev = ctx->dev; +unsigned long timeout; +u32 reg, ret =0 ; + + reg =coda_read (dev,CODA_REG_BIT_RUN_COMMAND ); +if (reg ==CODA_COMMAND_SEQ_INIT || reg ==CODA_COMMAND_PIC_RUN ) { + reg =coda_read (dev,CODA_REG_BIT_INT_REASON ); +if (coda_isbusy (dev,CODA_REG_BIT_BUSY ) || reg) { +/* +* Stop all of pipeline: +* subblk_man_mode[20] & cr_subblk_man_en[19:0] +*/ + reg = (CODA9_MBC_SET_SUBBLK_EN_MANUAL |0x0 ) & +CODA9_MBC_SET_SUBBLK_EN_MASK ; +coda_write (dev, reg,CODA9_MBC_SET_SUBBLK_EN ); + +/* Force to set the end of Bitstream to be decoded */ +coda_bit_stream_end_flag (ctx); + +/* +* Make the write pointer (where the buffer is being filled up) +* equal to read pointer (where VPU is reading stream data +* from the buffer) +*/ + reg =coda_read (dev,CODA_REG_BIT_RD_PTR (ctx->reg_idx)); +coda_write (dev, reg,CODA_REG_BIT_WR_PTR (ctx->reg_idx)); + + ret =coda_wait_timeout (dev,CODA_REG_BIT_BUSY ); +if (!ret) { +dev_err (dev->dev,"Error! Timeout waiting for interrupt while hw reset\n" ); +return -ETIME ; + } + } + } + +/* / Waiting for completion of BWB transaction first */ +if (coda_wait_timeout (dev,CODA9_GDI_BWB_STATUS )) { +dev_err (dev->dev,"Error! Timeout waiting for completion of BWB transaction\n" ); +return -ETIME ; + } + +/* No more requests */ +coda_write (dev,0x11 ,CODA9_GDI_BUS_CTRL ); +/* Waiting for completion of bus transaction */ + timeout = jiffies +msecs_to_jiffies (100 ); +while (coda_read (dev,CODA9_GDI_BUS_STATUS ) !=0x77 ) { +if (time_after (jiffies, timeout)) { +coda_write (dev,0x0 ,CODA9_GDI_BUS_CTRL ); +dev_err (dev->dev,"Error! Timeout waiting for completion of BUS transaction\n" ); +return -ETIME ; + } +cpu_relax (); + } + +/* Software Reset Trigger */ + reg =CODA9_SW_RESET_BPU_CORE |CODA9_SW_RESET_BPU_BUS | +CODA9_SW_RESET_VCE_CORE |CODA9_SW_RESET_VCE_BUS ; + +dev_dbg (dev->dev,"ATTENTION! Resetting GDI: tiled map should be reconfigured\n" ); + +coda_write (dev, reg,CODA9_REG_BIT_SW_RESET ); + +/* Wait until reset is done */ +if (coda_wait_timeout (dev,CODA9_REG_BIT_SW_RESET_STATUS )) { +dev_err (dev->dev,"Error! Timeout waiting for completion of SW reset\n" ); + ret = -ETIME ; + } + +coda_write (dev,0x0 ,CODA9_REG_BIT_SW_RESET ); +coda_write (dev,0x0 ,CODA9_GDI_BUS_CTRL ); + +return ret; +} +int coda_hw_reset (struct coda_ctx *ctx) {struct coda_dev *dev = ctx->dev;
@@ -129,15 +298,21 @@ int coda_hw_reset(struct coda_ctx *ctx) } } +if (dev->devtype->product ==CODA_988 ) { + ret =coda988_hw_runtime_reset (ctx); +if (ret) +return ret; + } + ret =reset_control_reset (dev->rstc);if (ret <0 )return ret; -if (dev->devtype->product ==CODA_960 ) +if (dev->devtype->product ==CODA_960 || dev->devtype->product ==CODA_988 )coda_write (dev,0x00 ,CODA9_GDI_BUS_CTRL );coda_write (dev,CODA_REG_BIT_BUSY_FLAG ,CODA_REG_BIT_BUSY );coda_write (dev,CODA_REG_RUN_ENABLE ,CODA_REG_BIT_CODE_RUN ); - ret =coda_wait_timeout (dev); + ret =coda_wait_timeout (dev,CODA_REG_BIT_BUSY );coda_write (dev, idx,CODA_REG_BIT_RUN_INDEX );return ret;
@@ -235,6 +410,7 @@ static u32 coda_buffer_parse_headers(struct coda_ctx *ctx,case V4L2_PIX_FMT_MPEG2 : size =coda_mpeg2_parse_headers (ctx, vaddr, payload);break ; +case V4L2_PIX_FMT_H263 :case V4L2_PIX_FMT_MPEG4 : size =coda_mpeg4_parse_headers (ctx, vaddr, payload);break ;
@@ -284,7 +460,8 @@ static bool coda_bitstream_try_queue(struct coda_ctx *ctx, "bitstream buffer overflow\n");return false; } -if (ctx->dev->devtype->product ==CODA_960 ) +if (ctx->dev->devtype->product ==CODA_960 || + ctx->dev->devtype->product ==CODA_988 )break ; } }else {
@@ -338,21 +515,23 @@ void coda_fill_bitstream(struct coda_ctx *ctx, struct list_head *buffer_list) ctx->num_metas > 1)break ; -if (ctx->num_internal_frames && - ctx->num_metas >= ctx->num_internal_frames) { - meta =list_first_entry (&ctx->buffer_meta_list, - struct coda_buffer_meta, list); - -/* -* If we managed to fill in at least a full reorder -* window of buffers (num_internal_frames is a -* conservative estimate for this) and the bitstream -* prefetcher has at least 2 256 bytes periods beyond -* the first buffer to fetch, we can safely stop queuing -* in order to limit the decoder drain latency. -*/ -if (coda_bitstream_can_fetch_past (ctx, meta->end)) -break ; +if (ctx->dev->devtype->product !=CODA_988 ) { +if (ctx->num_internal_frames && + ctx->num_metas >= ctx->num_internal_frames) { + meta =list_first_entry (&ctx->buffer_meta_list, + struct coda_buffer_meta, list); + +/* +* If we managed to fill in at least a full reorder +* window of buffers (num_internal_frames is a +* conservative estimate for this) and the bitstream +* prefetcher has at least 2 256 bytes periods beyond +* the first buffer to fetch, we can safely stop queuing +* in order to limit the decoder drain latency. +*/ +if (coda_bitstream_can_fetch_past (ctx, meta->end)) +break ; + } } src_buf =v4l2_m2m_next_src_buf (ctx->fh.m2m_ctx);
@@ -377,6 +556,31 @@ void coda_fill_bitstream(struct coda_ctx *ctx, struct list_head *buffer_list)continue ; } +if (ctx->codec->src_fourcc ==V4L2_PIX_FMT_VP8 && + ctx->dev->devtype->product ==CODA_988 ){ +unsigned long payload_len; +int ret =0 ; + + payload_len =vb2_get_plane_payload (&src_buf->vb2_buf,0 ); + +if (ctx->params.vp8_fill_ivf_header) { +u8 dummy_ivf_header[32 ] ="DKIF\x00\x00\x20\x00" ; + + ret |=coda_bitstream_queue (ctx, dummy_ivf_header, +sizeof (dummy_ivf_header)); + ctx->params.vp8_fill_ivf_header =0 ; + } +u8 frame_header[12 ]; + *(unsigned long *)frame_header = payload_len; +v4l2_dbg (3 , coda_debug, &ctx->dev->v4l2_dev, +"%s: feeding frame header into bitstream, frame len 0x%08lX\n" , + __func__, payload_len); + ret |=coda_bitstream_queue (ctx, frame_header,sizeof (frame_header)); +if (ret) +v4l2_err (&ctx->dev->v4l2_dev, +"failed to add VP8 header into bitstream\n" ); + } +/* Dump empty buffers */ if (!vb2_get_plane_payload (&src_buf->vb2_buf,0 )) { src_buf =v4l2_m2m_src_buf_remove (ctx->fh.m2m_ctx);
@@ -436,9 +640,9 @@ void coda_bit_stream_end_flag(struct coda_ctx *ctx) ctx->bit_stream_param |=CODA_BIT_STREAM_END_FLAG ;/* If this context is currently running, update the hardware flag */ -if ((dev->devtype->product ==CODA_960 ) && -coda_isbusy (dev) && - (ctx->idx ==coda_read (dev,CODA_REG_BIT_RUN_INDEX ))) { +if ((dev->devtype->product ==CODA_960 || dev->devtype->product ==CODA_988 ) && +coda_isbusy (dev,CODA_REG_BIT_BUSY ) && + ctx->idx ==coda_read (dev,CODA_REG_BIT_RUN_INDEX )) {coda_write (dev, ctx->bit_stream_param,CODA_REG_BIT_BIT_STREAM_PARAM ); }
@@ -475,23 +679,35 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx, struct coda_q_data *q_data, u32 fourcc) {struct coda_dev *dev = ctx->dev; -unsigned int ysize, ycbcr_size; +unsigned int width, height, ysize, ycbcr_size, size_mvcolbuf; +unsigned char round;int ret;int i;if (ctx->codec->src_fourcc ==V4L2_PIX_FMT_H264 || ctx->codec->dst_fourcc ==V4L2_PIX_FMT_H264 || + ctx->codec->dst_fourcc ==V4L2_PIX_FMT_H263 || + ctx->codec->src_fourcc ==V4L2_PIX_FMT_H263 || ctx->codec->src_fourcc ==V4L2_PIX_FMT_MPEG4 || - ctx->codec->dst_fourcc ==V4L2_PIX_FMT_MPEG4 ) - ysize =round_up (q_data->rect.width,16 ) * -round_up (q_data->rect.height,16 ); -else - ysize =round_up (q_data->rect.width,8 ) * q_data->rect.height; + ctx->codec->dst_fourcc ==V4L2_PIX_FMT_MPEG4 || + ctx->codec->src_fourcc ==V4L2_PIX_FMT_VP8 ) { + round = (dev->devtype->product ==CODA_988 ) ?32 :16 ; + height =round_up (q_data->rect.height, round); + width =round_up (q_data->rect.width, round); + }else { + height = q_data->rect.height; + width = (dev->devtype->product ==CODA_988 ) ? +round_up (q_data->rect.width,32 ) : +round_up (q_data->rect.width,8 ); + } -if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) - ycbcr_size =round_up (ysize,4096 ) + ysize /2 ; -else + ysize = height * width; +if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) { + round = (dev->devtype->product ==CODA_988 ) ?16384 :4096 ; + ycbcr_size =round_up (ysize, round) +round_up (ysize /2 , round); + }else { ycbcr_size = ysize + ysize /2 ; + }/* Allocate frame buffers */ for (i =0 ; i < ctx->num_internal_frames; i++) {
@@ -501,8 +717,20 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx,/* Add space for mvcol buffers */ if (dev->devtype->product !=CODA_DX6 && (ctx->codec->src_fourcc ==V4L2_PIX_FMT_H264 || - (ctx->codec->src_fourcc ==V4L2_PIX_FMT_MPEG4 && i ==0 ))) - size += ysize /4 ; + (ctx->codec->src_fourcc ==V4L2_PIX_FMT_H263 && i ==0 ) || + (ctx->codec->src_fourcc ==V4L2_PIX_FMT_MPEG4 && i ==0 ))) { +/* TODO add check for AVS format */ +if (dev->devtype->product ==CODA_988 ) { + size_mvcolbuf =round_up (q_data->rect.height,32 ) * +round_up (q_data->rect.width,32 ); + size_mvcolbuf = (size_mvcolbuf *3 ) /2 ; + size_mvcolbuf = (size_mvcolbuf +4 ) /5 ; + size_mvcolbuf = ((size_mvcolbuf +7 ) /8 ) *8 ; + }else { + size_mvcolbuf = ysize /4 ; + } + size += size_mvcolbuf; + } name =kasprintf (GFP_KERNEL ,"fb%d" , i);if (!name) {coda_free_framebuffers (ctx);
@@ -527,13 +755,19 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx, cr = y + ysize + ysize/4 ; mvcol = y + ysize + ysize/4 + ysize/4 ;if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) { - cb =round_up (cb,4096 ); - mvcol = cb + ysize/2 ; - cr =0 ; -/* Packed 20-bit MSB of base addresses */ -/* YYYYYCCC, CCyyyyyc, cccc.... */ - y = (y &0xfffff000 ) | cb >>20 ; - cb = (cb &0x000ff000 ) <<12 ; +if (dev->devtype->product ==CODA_988 ) { +/* We assume that Linear Frame Map is used */ + cb = y +round_up (ysize,16384 ); + cr = cb +round_up (ysize /2 ,16384 ); + }else { + cb =round_up (cb,4096 ); + mvcol = cb + ysize /2 ; + cr =0 ; +/* Packed 20-bit MSB of base addresses */ +/* YYYYYCCC, CCyyyyyc, cccc.... */ + y = (y &0xfffff000 ) | cb >>20 ; + cb = (cb &0x000ff000 ) <<12 ; + } }coda_parabuf_write (ctx, i *3 +0 , y);coda_parabuf_write (ctx, i *3 +1 , cb);
@@ -547,6 +781,17 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx,coda_parabuf_write (ctx,96 + i, mvcol);if (ctx->codec->src_fourcc ==V4L2_PIX_FMT_MPEG4 && i ==0 )coda_parabuf_write (ctx,97 , mvcol); + +if (ctx->codec->src_fourcc ==V4L2_PIX_FMT_H263 && i ==0 ) +coda_parabuf_write (ctx,97 , mvcol); + +/* Bottom addresses of framebuffer */ +if (dev->devtype->product ==CODA_988 && + ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) { +coda_parabuf_write (ctx, i *3 +0 +CODA988_FB_BOT_BYTE_OFFSET /4 ,0 ); +coda_parabuf_write (ctx, i *3 +1 +CODA988_FB_BOT_BYTE_OFFSET /4 ,0 ); +coda_parabuf_write (ctx, i *3 +2 +CODA988_FB_BOT_BYTE_OFFSET /4 ,0 ); + } }return 0 ;
@@ -556,6 +801,7 @@ static void coda_free_context_buffers(struct coda_ctx *ctx) {struct coda_dev *dev = ctx->dev; +coda_free_aux_buf (dev, &ctx->vp8mbbuf);coda_free_aux_buf (dev, &ctx->slicebuf);coda_free_aux_buf (dev, &ctx->psbuf);if (dev->devtype->product !=CODA_DX6 )
@@ -581,9 +827,13 @@ static int coda_alloc_context_buffers(struct coda_ctx *ctx,return 0 ;if (!ctx->slicebuf.vaddr && q_data->fourcc ==V4L2_PIX_FMT_H264 ) { -/* worst case slice size */ - size = (unsigned long )(DIV_ROUND_UP (q_data->rect.width,16 ) * -DIV_ROUND_UP (q_data->rect.height,16 )) *3200 /8 +512 ; +if (dev->devtype->product ==CODA_988 ) { + size = ctx->codec->max_h * ctx->codec->max_w *3 /4 ; + }else { +/* worst case slice size */ + size = (unsigned long )(DIV_ROUND_UP (q_data->rect.width,16 ) * +DIV_ROUND_UP (q_data->rect.height,16 )) *3200 /8 +512 ; + } ret =coda_alloc_context_buf (ctx, &ctx->slicebuf, size,"slicebuf" );if (ret <0 )
@@ -603,12 +853,29 @@ static int coda_alloc_context_buffers(struct coda_ctx *ctx,if (dev->devtype->product ==CODA_960 && q_data->fourcc ==V4L2_PIX_FMT_H264 ) size +=CODA9_PS_SAVE_SIZE ; +if (dev->devtype->product ==CODA_988 && + q_data->fourcc ==V4L2_PIX_FMT_H264 ) + size +=CODA988_PS_SAVE_SIZE ; ret =coda_alloc_context_buf (ctx, &ctx->workbuf, size,"workbuf" );if (ret <0 ) goto err; } +if (!ctx->vp8mbbuf.vaddr && q_data->fourcc ==V4L2_PIX_FMT_VP8 ) { +/* +* First partition information, 68 bytes per MB +* macroblock is 16x16 for Y component +*/ +unsigned int stride =round_up (q_data->width,16 ); + + size =68 * (stride * q_data->width /256 ); + ret =coda_alloc_context_buf (ctx, &ctx->vp8mbbuf, size, +"vp8mbbuf" ); +if (ret <0 ) + goto err; + } +return 0 ; err:
@@ -627,13 +894,13 @@ static int coda_encode_header(struct coda_ctx *ctx, struct vb2_v4l2_buffer *buf,int ret;int i; -if (dev->devtype->product ==CODA_960 ) +if (dev->devtype->product ==CODA_960 || ctx->dev->devtype->product ==CODA_988 )memset (vb2_plane_vaddr (vb,0 ),0 ,64 );coda_write (dev,vb2_dma_contig_plane_dma_addr (vb,0 ),CODA_CMD_ENC_HEADER_BB_START ); bufsize =vb2_plane_size (vb,0 ); -if (dev->devtype->product ==CODA_960 ) +if (dev->devtype->product ==CODA_960 || ctx->dev->devtype->product ==CODA_988 ) bufsize /=1024 ;coda_write (dev, bufsize,CODA_CMD_ENC_HEADER_BB_SIZE ); if (dev->devtype->product == CODA_960 &&
@@ -652,6 +919,62 @@ static int coda_encode_header(struct coda_ctx *ctx, struct vb2_v4l2_buffer *buf, CODA9_CMD_ENC_HEADER_FRAME_CROP_V); header_code |=CODA9_HEADER_FRAME_CROP ; } + }else if (ctx->dev->devtype->product ==CODA_988 && + ctx->codec->dst_fourcc ==V4L2_PIX_FMT_H264 ) { +int sps_id =0 ; + +if (header_code ==CODA_HEADER_H264_SPS_MVC ) + sps_id =1 ; + + q_data_src =get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_OUTPUT ); + r = &q_data_src->rect; + +if (header_code ==CODA_HEADER_H264_SPS || + header_code ==CODA_HEADER_H264_SPS_MVC ) { +coda_write (dev, +coda_h264enc_profile_id (ctx->params.h264_profile_idc), +CODA988_CMD_ENC_HEADER_PROFILE ); + +/* TODO 1 for monochrome yuv400 */ +coda_write (dev,0 , +CODA988_CMD_ENC_HEADER_CHROMA_FORMAT ); + +coda_write (dev,0 , +CODA988_CMD_ENC_HEADER_FIELD_FLAG ); + +if (r->width %32 || r->height %32 ) { +u32 crop_right =round_up (r->width,32 ) - r->width; +u32 crop_bottom =round_up (r->height,32 ) - r->height; + +coda_write (dev, crop_right, +CODA9_CMD_ENC_HEADER_FRAME_CROP_H ); +coda_write (dev, crop_bottom, +CODA9_CMD_ENC_HEADER_FRAME_CROP_V ); + header_code |=CODA988_HEADER_FRAME_CROP ; + } + }else if (header_code ==CODA_HEADER_H264_PPS || + header_code ==CODA_HEADER_H264_PPS_MVC ) { +int cabac_init_idc =0 ; +int pps_id =0 ; + +coda_write (dev, ctx->params.h264_entropy_mode, +CODA988_CMD_ENC_HEADER_CABAC_MODE ); +coda_write (dev, cabac_init_idc, +CODA988_CMD_ENC_HEADER_CABAC_INIT_IDC ); +if (ctx->params.h264_profile_idc >=V4L2_MPEG_VIDEO_H264_PROFILE_HIGH ) +coda_write (dev, ctx->params.h264_en_8x8_transform, +CODA988_CMD_ENC_HEADER_TRANSFORM_8X8 ); + +if (header_code ==CODA_HEADER_H264_PPS_MVC ) + header_code |= (1 <<24 ) | ((pps_id +1 ) <<16 ); +else + header_code |= (pps_id <<16 ); + } + +if (ctx->params.h264_level_idc) + header_code |=CODA988_HEADER_USER_LEVEL (ctx->params.h264_level_idc) | +CODA988_HEADER_USER_LEVEL_ENABLE ; + header_code |= (sps_id <<24 ); }coda_write (dev, header_code,CODA_CMD_ENC_HEADER_CODE ); ret =coda_command_sync (ctx,CODA_COMMAND_ENCODE_HEADER );
@@ -660,7 +983,7 @@ static int coda_encode_header(struct coda_ctx *ctx, struct vb2_v4l2_buffer *buf,return ret; } -if (dev->devtype->product ==CODA_960 ) { +if (dev->devtype->product ==CODA_960 || ctx->dev->devtype->product ==CODA_988 ) {for (i =63 ; i >0 ; i--)if (((char *)vb2_plane_vaddr (vb,0 ))[i] !=0 )break ;
@@ -697,6 +1020,28 @@ static u32 coda_slice_mode(struct coda_ctx *ctx) ((1 &CODA_SLICING_MODE_MASK ) <<CODA_SLICING_MODE_OFFSET ); } +static u32 coda988_slice_mode (struct coda_ctx *ctx) +{ +int size, unit; + +switch (ctx->params.slice_mode) { +case V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE : +default : +return 0 ; +case V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_MB : + size = ctx->params.slice_max_mb; + unit =2 ; +break ; +case V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_BYTES : + size = ctx->params.slice_max_bits; + unit =1 ; +break ; + } + +return ((size &CODA_SLICING_SIZE_MASK ) <<CODA_SLICING_SIZE_OFFSET ) | + ((unit &CODA988_SLICING_UNIT_MASK ) <<CODA988_SLICING_UNIT_OFFSET ); +} +static int coda_enc_param_change (struct coda_ctx *ctx) {struct coda_dev *dev = ctx->dev;
@@ -748,11 +1093,23 @@ static int coda_enc_param_change(struct coda_ctx *ctx) ctx->params.intra_refresh_changed = false; }if (ctx->params.slice_mode_changed) { +int value =0 ; + +if (dev->devtype->product ==CODA_988 ) + value =coda988_slice_mode (ctx); +else + value =coda_slice_mode (ctx); change_enable |=CODA_PARAM_CHANGE_SLICE_MODE ; -coda_write (dev,coda_slice_mode (ctx), +coda_write (dev, value,CODA_CMD_ENC_PARAM_SLICE_MODE ); ctx->params.slice_mode_changed = false; } +if (ctx->params.entropy_mode_changed) { + change_enable |=CODA988_ENC_CHANGE_PARAM_CABAC_MODE ; +coda_write (dev, ctx->params.h264_entropy_mode, +CODA988_CMD_ENC_PARAM_CHANGE_CABAC_MODE ); + ctx->params.entropy_mode_changed = false; + }if (!change_enable)return 0 ;
@@ -789,7 +1146,7 @@ static void coda_setup_iram(struct coda_ctx *ctx) {struct coda_iram_info *iram_info = &ctx->iram_info;struct coda_dev *dev = ctx->dev; -int w64, w128; +int w64, w128, w_bit;int mb_width;int dbk_bits;int bit_bits;
@@ -817,6 +1174,7 @@ static void coda_setup_iram(struct coda_ctx *ctx) me_bits =CODA7_USE_HOST_ME_ENABLE |CODA7_USE_ME_ENABLE ;break ;case CODA_960 : +case CODA_988 : dbk_bits =CODA9_USE_HOST_DBK_ENABLE |CODA9_USE_DBK_ENABLE ; bit_bits =CODA9_USE_HOST_BIT_ENABLE |CODA7_USE_BIT_ENABLE ; ip_bits =CODA9_USE_HOST_IP_ENABLE |CODA7_USE_IP_ENABLE ;
@@ -848,9 +1206,16 @@ static void coda_setup_iram(struct coda_ctx *ctx) iram_info->axi_sram_use |= me_bits; } -/* Only H.264BP and H.263P3 are considered */ - iram_info->buf_dbk_y_use =coda_iram_alloc (iram_info, w64); - iram_info->buf_dbk_c_use =coda_iram_alloc (iram_info, w64); +if (dev->devtype->product ==CODA_988 && + ctx->codec->src_fourcc ==V4L2_PIX_FMT_H264 ) { +/* H.264HP */ + iram_info->buf_dbk_y_use =coda_iram_alloc (iram_info, w128); + iram_info->buf_dbk_c_use =coda_iram_alloc (iram_info, w128); + }else { +/* Only H.264BP and H.263P3 are considered */ + iram_info->buf_dbk_y_use =coda_iram_alloc (iram_info, w64); + iram_info->buf_dbk_c_use =coda_iram_alloc (iram_info, w64); + }if (!iram_info->buf_dbk_y_use || !iram_info->buf_dbk_c_use) goto out; iram_info->axi_sram_use |= dbk_bits;
@@ -872,6 +1237,11 @@ static void coda_setup_iram(struct coda_ctx *ctx) q_data_dst =get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_CAPTURE ); mb_width =DIV_ROUND_UP (q_data_dst->width,16 ); w128 = mb_width *128 ; +if (ctx->codec->src_fourcc ==V4L2_PIX_FMT_H264 && + dev->devtype->product ==CODA_988 ) + w_bit = mb_width *144 ; +else + w_bit = mb_width *128 ; iram_info->buf_dbk_y_use =coda_iram_alloc (iram_info, w128); iram_info->buf_dbk_c_use =coda_iram_alloc (iram_info, w128);
@@ -879,7 +1249,7 @@ static void coda_setup_iram(struct coda_ctx *ctx) goto out; iram_info->axi_sram_use |= dbk_bits; - iram_info->buf_bit_use =coda_iram_alloc (iram_info, w128); + iram_info->buf_bit_use =coda_iram_alloc (iram_info, w_bit);if (!iram_info->buf_bit_use) goto out; iram_info->axi_sram_use |= bit_bits;
@@ -921,6 +1291,7 @@ static u32 coda_supported_firmwares[] = {CODA_FIRMWARE_VERNUM (CODA_960 ,2 ,1 ,9 ),CODA_FIRMWARE_VERNUM (CODA_960 ,2 ,3 ,10 ),CODA_FIRMWARE_VERNUM (CODA_960 ,3 ,1 ,1 ), + CODA_FIRMWARE_VERNUM(CODA_988, 3, 0, 1), };static bool coda_firmware_supported (u32 vernum)
@@ -951,14 +1322,17 @@ int coda_check_firmware(struct coda_dev *dev)coda_write (dev,CODA_REG_BIT_BUSY_FLAG ,CODA_REG_BIT_BUSY );coda_write (dev,0 ,CODA_REG_BIT_RUN_INDEX );coda_write (dev,0 ,CODA_REG_BIT_RUN_COD_STD ); +if (dev->devtype->product ==CODA_988 ) +coda_write (dev,0 ,CODA7_REG_BIT_RUN_AUX_STD ); +coda_write (dev,CODA_COMMAND_FIRMWARE_GET ,CODA_REG_BIT_RUN_COMMAND ); -if (coda_wait_timeout (dev)) { +if (coda_wait_timeout (dev,CODA_REG_BIT_BUSY )) {v4l2_err (&dev->v4l2_dev,"firmware get command error\n" ); ret = -EIO ; goto err_run_cmd; } -if (dev->devtype->product ==CODA_960 ) { +if (dev->devtype->product ==CODA_960 || dev->devtype->product ==CODA_988 ) { data =coda_read (dev,CODA9_CMD_FIRMWARE_CODE_REV );v4l2_info (&dev->v4l2_dev,"Firmware code revision: %d\n" , data);
@@ -1018,7 +1392,8 @@ static void coda9_set_frame_cache(struct coda_ctx *ctx, u32 fourcc) cache_config =1 <<CODA9_CACHE_PAGEMERGE_OFFSET ; }coda_write (ctx->dev, cache_size,CODA9_CMD_SET_FRAME_CACHE_SIZE ); -if (fourcc ==V4L2_PIX_FMT_NV12 || fourcc ==V4L2_PIX_FMT_YUYV ) { +if (fourcc ==V4L2_PIX_FMT_NV12 || fourcc ==V4L2_PIX_FMT_NV21 || + fourcc ==V4L2_PIX_FMT_YUYV ) { cache_config |=32 <<CODA9_CACHE_LUMA_BUFFER_SIZE_OFFSET |16 <<CODA9_CACHE_CR_BUFFER_SIZE_OFFSET |0 <<CODA9_CACHE_CB_BUFFER_SIZE_OFFSET ;
@@ -1030,6 +1405,21 @@ static void coda9_set_frame_cache(struct coda_ctx *ctx, u32 fourcc)coda_write (ctx->dev, cache_config,CODA9_CMD_SET_FRAME_CACHE_CONFIG ); } +static void coda988_set_frame_cache (struct coda_ctx *ctx,u32 fourcc) +{ +u32 cache_config =0 ; + + cache_config =CODA988_CACHE_BURST_MODE_4 | +CODA988_CACHE_CHROMA_INTERLEAVED_SZ_128_16 | +CODA988_CACHE_LUMA_SZ_128_32 | +CODA988_CACHE_LINE_VERT_PROC_MERGE ; + +if (ctx->tiled_map_type !=GDI_LINEAR_FRAME_MAP ) + cache_config |=CODA988_CACHE_MAP_TYPE_TILED ; + +coda_write (ctx->dev, cache_config,CODA9_CMD_SET_FRAME_CACHE_CONFIG ); +} +/* * Encoder context operations */
@@ -1105,6 +1495,7 @@ static int coda_start_encoding(struct coda_ctx *ctx) CODADX6_STREAM_BUF_PIC_RESET, CODA_REG_BIT_STREAM_CTRL);break ;case CODA_960 : +case CODA_988 :coda_write (dev,0 ,CODA9_GDI_WPROT_RGN_EN ); fallthrough;case CODA_HX4 :
@@ -1114,12 +1505,36 @@ static int coda_start_encoding(struct coda_ctx *ctx)break ; } - ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 <<9 ) | -CODA9_FRAME_TILED2LINEAR ); -if (q_data_src->fourcc ==V4L2_PIX_FMT_NV12 ) - ctx->frame_mem_ctrl |=CODA_FRAME_CHROMA_INTERLEAVE ; -if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) - ctx->frame_mem_ctrl |= (0x3 <<9 ) |CODA9_FRAME_TILED2LINEAR ; +if (dev->devtype->product ==CODA_988 ) { + ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | +CODA988_FRAME_CHROMA_NV21_SWAP | +CODA988_FRAME_TILED_MAP_MASK | +CODA988_FRAME_TILED2LINEAR_MASK ); + +if (q_data_src->fourcc ==V4L2_PIX_FMT_NV12 || + q_data_src->fourcc ==V4L2_PIX_FMT_NV21 || + q_data_src->fourcc ==V4L2_PIX_FMT_YUYV ) + ctx->frame_mem_ctrl |=CODA_FRAME_CHROMA_INTERLEAVE ; + +if (q_data_src->fourcc ==V4L2_PIX_FMT_NV21 ) + ctx->frame_mem_ctrl |=CODA988_FRAME_CHROMA_NV21_SWAP ; + +if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) { +dev_warn (dev->dev,"%s() :%d WARNING! Set TILED_FRAME_MB_RASTER\n" , + __func__, __LINE__); + ctx->frame_mem_ctrl |=CODA988_FRAME_TILED2LINEAR_FRAME_MAP | +CODA988_FRAME_TILED_MAP_TILED_FRAME_MB_RAST ; + } + + }else { + ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 <<9 ) | +CODA9_FRAME_TILED2LINEAR ); +if (q_data_src->fourcc ==V4L2_PIX_FMT_NV12 || + q_data_src->fourcc ==V4L2_PIX_FMT_NV21 ) + ctx->frame_mem_ctrl |=CODA_FRAME_CHROMA_INTERLEAVE ; +if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) + ctx->frame_mem_ctrl |= (0x3 <<9 ) |CODA9_FRAME_TILED2LINEAR ; + }coda_write (dev, ctx->frame_mem_ctrl,CODA_REG_BIT_FRAME_MEM_CTRL );if (dev->devtype->product ==CODA_DX6 ) {
@@ -1147,11 +1562,13 @@ static int coda_start_encoding(struct coda_ctx *ctx)break ; } fallthrough; +case CODA_988 :case CODA_960 : value = (q_data_src->rect.width &CODA7_PICWIDTH_MASK ) <<CODA7_PICWIDTH_OFFSET ; value |= (q_data_src->rect.height &CODA7_PICHEIGHT_MASK ) <<CODA_PICHEIGHT_OFFSET ; +break ; }coda_write (dev, value,CODA_CMD_ENC_SEQ_SRC_SIZE );if (dst_fourcc ==V4L2_PIX_FMT_JPEG )
@@ -1161,19 +1578,46 @@ static int coda_start_encoding(struct coda_ctx *ctx) ctx->params.codec_mode = ctx->codec->mode;switch (dst_fourcc) { +case V4L2_PIX_FMT_H263 : +if (dev->devtype->product ==CODA_960 || + dev->devtype->product ==CODA_988 ) +coda_write (dev,CODA9_STD_H263 ,CODA_CMD_ENC_SEQ_COD_STD ); +else +coda_write (dev,CODA_STD_H263 ,CODA_CMD_ENC_SEQ_COD_STD ); + value =0 ; +if (dev->devtype->product ==CODA_988 ) { + value =CODA988_H263_ANNEX_I_ENABLE <<3 | +CODA988_H263_ANNEX_J_ENABLE <<2 | +CODA988_H263_ANNEX_K_ENABLE <<1 | +CODA988_H263_ANNEX_T_ENABLE ; + } +coda_write (dev, value,CODA_CMD_ENC_SEQ_263_PARA ); +break ;case V4L2_PIX_FMT_MPEG4 : -if (dev->devtype->product ==CODA_960 ) -coda_write (dev,CODA9_STD_MPEG4 , -CODA_CMD_ENC_SEQ_COD_STD ); +if (dev->devtype->product ==CODA_960 || + dev->devtype->product ==CODA_988 ) +coda_write (dev,CODA9_STD_MPEG4 ,CODA_CMD_ENC_SEQ_COD_STD );else -coda_write (dev,CODA_STD_MPEG4 , -CODA_CMD_ENC_SEQ_COD_STD ); -coda_write (dev,0 ,CODA_CMD_ENC_SEQ_MP4_PARA ); +coda_write (dev,CODA_STD_MPEG4 ,CODA_CMD_ENC_SEQ_COD_STD ); + value =0 ; +if (dev->devtype->product ==CODA_988 ) { + value =CODA988_MP4_INTRA_DC_VLC_THR <<2 | +CODA988_MP4_REVERSIBLE_VLC_EN <<1 | +CODA988_MP4_DATA_PARTITION_EN ; + + value |= ((CODA988_MP4_HEC_EN >0 ) ?1 :0 ) <<5 ; + value |= ((CODA988_MP4_VER_ID ==2 ) ?0 :1 ) <<6 ; + } +coda_write (dev, value,CODA_CMD_ENC_SEQ_MP4_PARA );break ;case V4L2_PIX_FMT_H264 :if (dev->devtype->product ==CODA_960 )coda_write (dev,CODA9_STD_H264 ,CODA_CMD_ENC_SEQ_COD_STD ); +else if (dev->devtype->product ==CODA_988 ) +coda_write (dev,CODA9_STD_H264 | +coda_h264enc_profile_id (ctx->params.h264_profile_idc) <<4 , +CODA_CMD_ENC_SEQ_COD_STD );else coda_write (dev,CODA_STD_H264 ,CODA_CMD_ENC_SEQ_COD_STD );
@@ -1214,42 +1658,131 @@ static int coda_start_encoding(struct coda_ctx *ctx)* in JPEG mode */ if (dst_fourcc !=V4L2_PIX_FMT_JPEG ) { - value =coda_slice_mode (ctx); +if (dev->devtype->product ==CODA_988 ) + value =coda988_slice_mode (ctx); +else + value =coda_slice_mode (ctx);coda_write (dev, value,CODA_CMD_ENC_SEQ_SLICE_MODE ); - value = ctx->params.gop_size; -coda_write (dev, value,CODA_CMD_ENC_SEQ_GOP_SIZE ); }if (ctx->params.bitrate && (ctx->params.frame_rc_enable || ctx->params.mb_rc_enable)) { +int skip_frame = ctx->params.frame_skip_mode == +V4L2_MPEG_VIDEO_FRAME_SKIP_MODE_DISABLED ?1 :0 ; ctx->params.bitrate_changed = false; ctx->params.h264_intra_qp_changed = false; - -/* Rate control enabled */ - value = (ctx->params.bitrate &CODA_RATECONTROL_BITRATE_MASK ) - <<CODA_RATECONTROL_BITRATE_OFFSET ; - value |=1 &CODA_RATECONTROL_ENABLE_MASK ; - value |= (ctx->params.vbv_delay & -CODA_RATECONTROL_INITIALDELAY_MASK ) - <<CODA_RATECONTROL_INITIALDELAY_OFFSET ; -if (dev->devtype->product ==CODA_960 ) - value |=BIT (31 );/* disable autoskip */ +coda_dbg (1 , ctx,"CODA RateControl Enable\n" ); + +if (dev->devtype->product ==CODA_988 ) { + value = ctx->params.max_intra_size; +if (ctx->params.max_intra_size >0 ) + value = (1 <<16 ); +coda_write (dev, value,CODA988_CMD_ENC_SEQ_RC_MAX_INTRA_SIZE ); + +if (dst_fourcc ==V4L2_PIX_FMT_MPEG4 || + dst_fourcc ==V4L2_PIX_FMT_H263 ) { +coda_write (dev, ctx->params.gop_size,CODA_CMD_ENC_SEQ_GOP_SIZE ); + + value =CODA_RATECONTROL_AUTOSKIP_DISABLE (skip_frame); + value |=CODA_RATECONTROL_INITIALDELAY (ctx->params.vbv_delay); +coda_write (dev, value,CODA_CMD_ENC_SEQ_RC_PARA ); + + value =0 ; +coda_write (dev, value,CODA988_CMD_ENC_SEQ_QP_RANGE_SET ); + +/* For MPEG4 encoder, BitRateKBPS occupies [18:4] bit field */ + value = (min (ctx->params.bitrate,16383 ) <<4 ) |1 ; +coda_write (dev, value,CODA988_CMD_ENC_SEQ_RC_PARA2 ); + }else if (dst_fourcc ==V4L2_PIX_FMT_H264 ) { +/* +* -4..4 An initial QP offset for I in GOP. +* bit[3] is sign, bit[2..0] is value +* ex. -2 = BIT(3) | 2; +*/ +u8 gop_qp_offset =0 ; +bool gop_qp_en = false; +bool rc_cbr_srtict = false; +/* +* RC_MODE_OFF : Rate-control is off (Constant QP) +* RC_MODE_CBR : Rate-control is on (CBR) +* RC_MODE_ABR : Rate-control is on (ABR) recomended as default +* RC_MODE_VENDOR : Rate-control is on (Picture-level RC) +*/ +int rc_mode =CODA988_RC_MODE_OFF ; + +if (ctx->params.bitrate_mode ==V4L2_MPEG_VIDEO_BITRATE_MODE_CBR ) + rc_mode =CODA988_RC_MODE_CBR ; +else + rc_mode =CODA988_RC_MODE_ABR ; + +if (rc_mode ==CODA988_RC_MODE_CBR && ctx->params.vbv_delay <20000 ) + ctx->params.vbv_delay =20000 ; + + value = ctx->params.gop_size; + value |= (ctx->params.h264_i_frame_period <<21 ); + value |= gop_qp_en <<20 ; + value |= (gop_qp_offset &0xF ) <<16 ; + +coda_write (dev, value,CODA_CMD_ENC_SEQ_GOP_SIZE ); + + value =CODA_RATECONTROL_AUTOSKIP_DISABLE (skip_frame); + value |=CODA_RATECONTROL_INITIALDELAY (ctx->params.vbv_delay); +coda_write (dev, value,CODA_CMD_ENC_SEQ_RC_PARA ); + +if (rc_mode ==1 ) + value |= rc_cbr_srtict <<22 ; + value |= ((ctx->params.bitrate) <<4 ) | rc_mode; +coda_write (dev, value,CODA988_CMD_ENC_SEQ_RC_PARA2 ); + } + }else { +coda_write (dev, ctx->params.gop_size,CODA_CMD_ENC_SEQ_GOP_SIZE ); + value = (ctx->params.bitrate &CODA_RATECONTROL_BITRATE_MASK ) + <<CODA_RATECONTROL_BITRATE_OFFSET ; + value |=1 &CODA_RATECONTROL_ENABLE_MASK ; + value |=CODA_RATECONTROL_INITIALDELAY (ctx->params.vbv_delay); +if (dev->devtype->product ==CODA_960 ) + value |=BIT (31 );/* disable autoskip */ +coda_write (dev, value,CODA_CMD_ENC_SEQ_RC_PARA ); + } }else { +coda_dbg (1 , ctx,"CODA RateControl Disable\n" ); + value = ctx->params.gop_size; +if (dev->devtype->product ==CODA_988 && dst_fourcc ==V4L2_PIX_FMT_H264 ) + value |= (ctx->params.h264_i_frame_period <<21 ); + +coda_write (dev, value,CODA_CMD_ENC_SEQ_GOP_SIZE ); + value =0 ; +coda_write (dev, value,CODA_CMD_ENC_SEQ_RC_PARA ); +if (dev->devtype->product ==CODA_988 ) { +coda_write (dev,0 ,CODA988_CMD_ENC_SEQ_QP_RANGE_SET ); +coda_write (dev,0 ,CODA988_CMD_ENC_SEQ_RC_PARA2 ); + } } -coda_write (dev, value,CODA_CMD_ENC_SEQ_RC_PARA ); -coda_write (dev, ctx->params.vbv_size,CODA_CMD_ENC_SEQ_RC_BUF_SIZE ); + value =0 ; +if (ctx->params.vbv_size && dev->devtype->product ==CODA_988 ) + value = ctx->params.vbv_size |BIT (16 ); +else + value = ctx->params.vbv_size; +coda_write (dev, value,CODA_CMD_ENC_SEQ_RC_BUF_SIZE );coda_write (dev, ctx->params.intra_refresh,CODA_CMD_ENC_SEQ_INTRA_REFRESH ); + value =0 ; +if (ctx->params.intra_refresh && dev->devtype->product ==CODA_988 ) + value = ctx->params.intra_refresh |BIT (16 ); +else + value = ctx->params.intra_refresh; +coda_write (dev, value,CODA_CMD_ENC_SEQ_INTRA_REFRESH ); +coda_write (dev, bitstream_buf,CODA_CMD_ENC_SEQ_BB_START );coda_write (dev, bitstream_size /1024 ,CODA_CMD_ENC_SEQ_BB_SIZE ); value =0 ;if (ctx->params.gamma >0 ) { -if (dev->devtype->product ==CODA_960 ) +if (dev->devtype->product ==CODA_960 || dev->devtype->product ==CODA_988 ) value |=1 <<CODA9_OPTION_GAMMA_OFFSET ;else if (dev->devtype->product ==CODA_DX6 ) value |=1 <<CODADX6_OPTION_GAMMA_OFFSET ;
@@ -1258,13 +1791,66 @@ static int coda_start_encoding(struct coda_ctx *ctx)coda_write (dev, ctx->params.gamma,CODA_CMD_ENC_SEQ_RC_GAMMA ); } -if (ctx->params.h264_min_qp || ctx->params.h264_max_qp) { +if (dev->devtype->product ==CODA_988 ) { +int qp_range_h264 =0 ; +int qp_range_mpeg =0 ; +int qp_delta_h264 =0 ; + +/* min/max qp special for every frame type (I/P) used first */ +/* min/max qp common for all frame type (I/P) used second */ +if (dst_fourcc ==V4L2_PIX_FMT_H264 ) { +/* TODO delta QP don't use now */ +int min_delta_qp =0 ; +int max_delta_qp =0 ; + +if (min_delta_qp >0 ) + qp_delta_h264 = (BIT (6 ) | min_delta_qp) <<8 ; + +if (max_delta_qp >0 ) + qp_delta_h264 =BIT (6 ) | max_delta_qp; + +if (ctx->params.h264_min_i_qp) + qp_range_h264 |= (BIT (6 ) | ctx->params.h264_min_i_qp); +else if (ctx->params.h264_min_qp) + qp_range_h264 |= (BIT (6 ) | ctx->params.h264_min_qp); + +if (ctx->params.h264_max_i_qp) + qp_range_h264 |= (BIT (6 ) | ctx->params.h264_max_i_qp) <<8 ; +else if (ctx->params.h264_max_qp) + qp_range_h264 |= (BIT (6 ) | ctx->params.h264_max_qp) <<8 ; + +if (ctx->params.h264_min_p_qp) + qp_range_h264 |= (BIT (6 ) | ctx->params.h264_min_p_qp) <<16 ; +else if (ctx->params.h264_min_qp) + qp_range_h264 |= (BIT (6 ) | ctx->params.h264_min_qp) <<16 ; + +if (ctx->params.h264_max_p_qp) + qp_range_h264 |= (BIT (6 ) | ctx->params.h264_max_p_qp) <<24 ; +else if (ctx->params.h264_max_qp) + qp_range_h264 |= (BIT (6 ) | ctx->params.h264_max_qp) <<24 ; + }else if (dst_fourcc ==V4L2_PIX_FMT_MPEG4 ) { + qp_range_mpeg = ctx->params.mpeg4_max_qp; + }else if (dst_fourcc ==V4L2_PIX_FMT_H263 ) { + qp_range_mpeg = ctx->params.h263_max_qp; + } + +coda_write (dev, qp_delta_h264,CODA988_CMD_ENC_SEQ_DELTA_QP ); +coda_write (dev, qp_range_mpeg,CODA988_CMD_ENC_SEQ_RC_QP_MAX ); +coda_write (dev, qp_range_h264,CODA988_CMD_ENC_SEQ_QP_RANGE_SET ); + }else if (dst_fourcc ==V4L2_PIX_FMT_H264 || + ctx->params.h264_min_qp || + ctx->params.h264_max_qp) {coda_write (dev, ctx->params.h264_min_qp <<CODA_QPMIN_OFFSET | ctx->params.h264_max_qp <<CODA_QPMAX_OFFSET ,CODA_CMD_ENC_SEQ_RC_QP_MIN_MAX ); + }else { +coda_write (dev,0 ,CODA_CMD_ENC_SEQ_RC_QP_MIN_MAX ); } -if (dev->devtype->product ==CODA_960 ) { + +if (dev->devtype->product ==CODA_988 ) { + value |= ctx->params.encode_aud_en <<2 ; + }else if (dev->devtype->product ==CODA_960 ) {if (ctx->params.h264_max_qp) value |=1 <<CODA9_OPTION_RCQPMAX_OFFSET ; }else {
@@ -1275,10 +1861,16 @@ static int coda_start_encoding(struct coda_ctx *ctx) }coda_write (dev, value,CODA_CMD_ENC_SEQ_OPTION ); -if (ctx->params.frame_rc_enable && !ctx->params.mb_rc_enable) - value =1 ; -else +if (dev->devtype->product ==CODA_988 ) { +/* TODO check mode = 3 */ value =0 ; + }else { +if (ctx->params.frame_rc_enable && !ctx->params.mb_rc_enable) + value =1 ; +else + value =0 ; + } +coda_write (dev, value,CODA_CMD_ENC_SEQ_RC_INTERVAL_MODE );coda_setup_iram (ctx);
@@ -1299,6 +1891,40 @@ static int coda_start_encoding(struct coda_ctx *ctx)case CODA_960 :coda_write (dev,0 ,CODA9_CMD_ENC_SEQ_ME_OPTION );coda_write (dev,0 ,CODA9_CMD_ENC_SEQ_INTRA_WEIGHT ); +break ; +case CODA_988 : +/* An intra cost weight factor for Intra/Inter type decision */ +u32 intra_const_weight =0 ; +/* A block mode enable flag for Motion Estimation */ +u32 me_blk_mode =0 ; +/* A Motion Estimation PMV option */ +u32 me_use_zero_pmv =0 ; +/* A line buffer mode for Motion Estimation*/ +u32 me_line_buf_mode =2 ; + +/* For conservative operation as defined in each of the video codec +* specification, it would be better to set 0 for H.264/AVC encoder +* and 1 for MPEG-4 encoder. +* Programmer's Guide Version 3.13.45.4 page 205 +*/ +if (dst_fourcc ==V4L2_PIX_FMT_MPEG4 || dst_fourcc ==V4L2_PIX_FMT_H263 ) + me_use_zero_pmv =1 ; + +/* always use constant values for h.263 */ +if (dst_fourcc ==V4L2_PIX_FMT_H263 ) { + ctx->params.me_search_range_y =3 ; + ctx->params.me_search_range_x =2 ; + } + + value =CODA9_CMD_ENC_SEQ_ME_LINE_BUF_MODE (me_line_buf_mode) | +CODA9_CMD_ENC_SEQ_ME_BLK_MODE_EN (me_blk_mode) | +CODA9_CMD_ENC_SEQ_ME_USE_ZERO_PMV (me_use_zero_pmv) | +CODA9_CMD_ENC_SEQ_ME_SEARCH_RANGE_X (ctx->params.me_search_range_y) | +CODA9_CMD_ENC_SEQ_ME_SEARCH_RANGE_X (ctx->params.me_search_range_x); +coda_write (dev, value,CODA9_CMD_ENC_SEQ_ME_OPTION ); +coda_write (dev, intra_const_weight, +CODA9_CMD_ENC_SEQ_INTRA_WEIGHT ); +break ; } }
@@ -1316,7 +1942,7 @@ static int coda_start_encoding(struct coda_ctx *ctx) ctx->initialized =1 ;if (dst_fourcc !=V4L2_PIX_FMT_JPEG ) { -if (dev->devtype->product ==CODA_960 ) +if (dev->devtype->product ==CODA_960 || dev->devtype->product ==CODA_988 ) ctx->num_internal_frames =4 ;else ctx->num_internal_frames =2 ;
@@ -1362,6 +1988,8 @@ static int coda_start_encoding(struct coda_ctx *ctx) CODA9_CMD_SET_FRAME_SUBSAMP_A);coda_write (dev, ctx->internal_frames[3 ].buf.paddr,CODA9_CMD_SET_FRAME_SUBSAMP_B ); + }else if (dev->devtype->product ==CODA_988 ) { +coda988_set_frame_cache (ctx, q_data_src->fourcc); } }
@@ -1395,12 +2023,13 @@ static int coda_start_encoding(struct coda_ctx *ctx)* If visible width or height are not aligned to macroblock * size, the crop_right and crop_bottom SPS fields must be set * to the difference between visible and coded size. This is -* only supported by CODA960 firmware. All others do not allow +* only supported by CODA960/980 firmware. All others do not allow * writing frame cropping parameters, so we have to manually * fix up the SPS RBSP (Sequence Parameter Set Raw Byte * Sequence Payload) ourselves. */ if (ctx->dev->devtype->product !=CODA_960 && + dev->devtype->product !=CODA_988 && ((q_data_src->rect.width %16 ) || (q_data_src->rect.height %16 ))) { ret = coda_h264_sps_fixup(ctx, q_data_src->rect.width,
@@ -1455,6 +2084,8 @@ static int coda_start_encoding(struct coda_ctx *ctx)if (ret <0 ) goto out;break ; +case V4L2_PIX_FMT_H263 : +/* In H.263, ENC_HEADER command is ignored.*/ default :/* No more formats need to save headers at the moment */ break ;
@@ -1556,6 +2187,9 @@ static int coda_prepare_encode(struct coda_ctx *ctx)case V4L2_PIX_FMT_JPEG : quant_param =30 ;break ; +case V4L2_PIX_FMT_H263 : + quant_param = ctx->params.h263_intra_qp; +break ;default :v4l2_warn (&ctx->dev->v4l2_dev,"cannot set intra qp, fmt not supported\n" );
@@ -1569,6 +2203,9 @@ static int coda_prepare_encode(struct coda_ctx *ctx)case V4L2_PIX_FMT_MPEG4 : quant_param = ctx->params.mpeg4_inter_qp;break ; +case V4L2_PIX_FMT_H263 : + quant_param = ctx->params.h263_inter_qp; +break ;default :v4l2_warn (&ctx->dev->v4l2_dev,"cannot set inter qp, fmt not supported\n" );
@@ -1579,14 +2216,25 @@ static int coda_prepare_encode(struct coda_ctx *ctx)/* submit */ if (ctx->params.rot_mode) rot_mode =CODA_ROT_MIR_ENABLE | ctx->params.rot_mode; + +if (dev->devtype->product ==CODA_988 ) { +if (q_data_src->fourcc ==V4L2_PIX_FMT_NV12 || + q_data_src->fourcc ==V4L2_PIX_FMT_NV21 ) + rot_mode |=CODA988_CBCR_INTERLIVE ; +if (q_data_src->fourcc ==V4L2_PIX_FMT_NV21 ) + rot_mode |=CODA988_SELECT_NV21 ; + }coda_write (dev, rot_mode,CODA_CMD_ENC_PIC_ROT_MODE );coda_write (dev, quant_param,CODA_CMD_ENC_PIC_QS ); -if (dev->devtype->product ==CODA_960 ) { +if (dev->devtype->product ==CODA_960 || + dev->devtype->product ==CODA_988 ) {coda_write (dev,4 /*FIXME: 0*/ ,CODA9_CMD_ENC_PIC_SRC_INDEX );coda_write (dev, q_data_src->bytesperline,CODA9_CMD_ENC_PIC_SRC_STRIDE ); -coda_write (dev,0 ,CODA9_CMD_ENC_PIC_SUB_FRAME_SYNC ); + +if (dev->devtype->product ==CODA_960 ) +coda_write (dev,0 ,CODA9_CMD_ENC_PIC_SUB_FRAME_SYNC ); reg =CODA9_CMD_ENC_PIC_SRC_ADDR_Y ; }else {
@@ -1712,7 +2360,8 @@ static void coda_seq_end_work(struct work_struct *work)* from the output stream after the h.264 decoder has run. Resetting the * hardware after the decoder has finished seems to help. */ -if (dev->devtype->product ==CODA_960 ) +if (dev->devtype->product ==CODA_960 || + dev->devtype->product ==CODA_988 )coda_hw_reset (ctx); kfifo_init(&ctx->bitstream_fifo,
@@ -1815,7 +2464,8 @@ static bool coda_reorder_enable(struct coda_ctx *ctx)if (dev->devtype->product !=CODA_HX4 && dev->devtype->product !=CODA_7541 && - dev->devtype->product !=CODA_960 ) + dev->devtype->product !=CODA_960 && + dev->devtype->product !=CODA_988 )return false;if (ctx->codec->src_fourcc ==V4L2_PIX_FMT_JPEG )
@@ -1864,7 +2514,9 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx)int width, height;u32 src_fourcc, dst_fourcc;u32 val; -int ret; +u8 crop_shift; +u16 crop_mask; +int ret =0 ;lockdep_assert_held (&dev->coda_mutex);
@@ -1882,13 +2534,27 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx)/* Update coda bitstream read and write pointers from kfifo */ coda_kfifo_sync_to_device_full (ctx); - ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 <<9 ) | -CODA9_FRAME_TILED2LINEAR ); -if (dst_fourcc ==V4L2_PIX_FMT_NV12 || dst_fourcc ==V4L2_PIX_FMT_YUYV ) +if (dev->devtype->product ==CODA_988 ) { + ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | +CODA988_FRAME_CHROMA_NV21_SWAP | +CODA988_FRAME_TILED_MAP_MASK | +CODA988_FRAME_TILED2LINEAR_MASK ); +if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) { + ctx->frame_mem_ctrl |=CODA988_FRAME_TILED2LINEAR_FRAME_MAP | +CODA988_FRAME_TILED_MAP_TILED_FRAME_MB_RAST ; + } + }else { + ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 <<9 ) | +CODA9_FRAME_TILED2LINEAR ); +if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) + ctx->frame_mem_ctrl |= (0x3 <<9 ) | + ((ctx->use_vdoa) ?0 :CODA9_FRAME_TILED2LINEAR ); + } +if (dst_fourcc ==V4L2_PIX_FMT_NV12 || dst_fourcc ==V4L2_PIX_FMT_NV21 || + dst_fourcc ==V4L2_PIX_FMT_YUYV ) ctx->frame_mem_ctrl |=CODA_FRAME_CHROMA_INTERLEAVE ; -if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) - ctx->frame_mem_ctrl |= (0x3 <<9 ) | - ((ctx->use_vdoa) ?0 :CODA9_FRAME_TILED2LINEAR ); +if (dst_fourcc ==V4L2_PIX_FMT_NV21 && dev->devtype->product ==CODA_988 ) + ctx->frame_mem_ctrl |=CODA988_FRAME_CHROMA_NV21_SWAP ;coda_write (dev, ctx->frame_mem_ctrl,CODA_REG_BIT_FRAME_MEM_CTRL ); ctx->display_idx =-1 ;
@@ -1897,6 +2563,12 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx)coda_write (dev, bitstream_buf,CODA_CMD_DEC_SEQ_BB_START );coda_write (dev, bitstream_size /1024 ,CODA_CMD_DEC_SEQ_BB_SIZE ); +if (dev->devtype->product ==CODA_988 ) { +coda_write (dev,0x0 ,CODA988_CMD_DEC_SEQ_USER_DATA_OPTION ); +coda_write (dev,0x0 ,CODA988_CMD_DEC_SEQ_USER_DATA_BASE_ADDR ); +coda_write (dev,0x0 ,CODA988_CMD_DEC_SEQ_USER_DATA_BUF_SIZE ); + } + val =0 ;if (coda_reorder_enable (ctx)) val |=CODA_REORDER_ENABLE ;
@@ -1908,6 +2580,16 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx)if (dev->devtype->product ==CODA_960 && src_fourcc ==V4L2_PIX_FMT_MPEG4 ) ctx->params.codec_mode_aux =CODA_MP4_AUX_MPEG4 ; +else if (dev->devtype->product ==CODA_988 ) { +if (src_fourcc ==V4L2_PIX_FMT_MPEG4 || src_fourcc ==V4L2_PIX_FMT_H263 ) + ctx->params.codec_mode_aux =CODA_MP4_AUX_MPEG4 ; +if (src_fourcc ==V4L2_PIX_FMT_VP8 ) + ctx->params.codec_mode_aux =CODA_VPX_AUX_VP8 ; +if (src_fourcc ==V4L2_PIX_FMT_H264_MVC ) + ctx->params.codec_mode_aux =CODA_H264_AUX_MVC ; +if (src_fourcc ==V4L2_PIX_FMT_H264 ) + ctx->params.codec_mode_aux =CODA_H264_AUX_AVC ; + }else ctx->params.codec_mode_aux =0 ;if (src_fourcc ==V4L2_PIX_FMT_MPEG4 ) {
@@ -1925,14 +2607,22 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx)if (dev->devtype->product ==CODA_960 ) {coda_write (dev,0 ,CODA_CMD_DEC_SEQ_X264_MV_EN );coda_write (dev,512 ,CODA_CMD_DEC_SEQ_SPP_CHUNK_SIZE ); + }else if (dev->devtype->product ==CODA_988 ) { +coda_write (dev,1 ,CODA_CMD_DEC_SEQ_X264_MV_EN ); +coda_write (dev,1024 ,CODA_CMD_DEC_SEQ_SPP_CHUNK_SIZE ); } }if (src_fourcc ==V4L2_PIX_FMT_JPEG )coda_write (dev,0 ,CODA_CMD_DEC_SEQ_JPG_THUMB_EN ); -if (dev->devtype->product !=CODA_960 ) +if (dev->devtype->product !=CODA_960 && dev->devtype->product !=CODA_988 )coda_write (dev,0 ,CODA_CMD_DEC_SEQ_SRC_SIZE ); - ctx->bit_stream_param =CODA_BIT_DEC_SEQ_INIT_ESCAPE ; +/* SeqInitEscape flag is obsoleted for coda988 */ +if (dev->devtype->product ==CODA_988 ) + ctx->bit_stream_param =0x0 ; +else + ctx->bit_stream_param =CODA_BIT_DEC_SEQ_INIT_ESCAPE ; + ret =coda_command_sync (ctx,CODA_COMMAND_SEQ_INIT ); ctx->bit_stream_param =0 ;if (ret) {
@@ -1981,6 +2671,16 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx)coda_dbg (1 , ctx,"start decoding: %dx%d\n" , width, height); ctx->num_internal_frames =coda_read (dev,CODA_RET_DEC_SEQ_FRAME_NEED ); + +/* +* For coda988 there is a bug with the number of required frame buffers. +* We need at least 8 to avoid getting "-1" in CODA_RET_DEC_PIC_CUR_IDX reg +* that means BIT does not decode a picture at this picture run command +* because there is not enough frame buffer to continue decoding process. +*/ +if (dev->devtype->product ==CODA_988 ) + ctx->num_internal_frames =max (ctx->num_internal_frames,CODA988_MIN_FRAMEBUFFERS ); +/* * If the VDOA is used, the decoder needs one additional frame, * because the frames are freed when the next frame is decoded.
@@ -2004,12 +2704,20 @@ static int __coda_decoder_seq_init(struct coda_ctx *ctx) left_right =coda_read (dev,CODA_RET_DEC_SEQ_CROP_LEFT_RIGHT ); top_bottom =coda_read (dev,CODA_RET_DEC_SEQ_CROP_TOP_BOTTOM ); - q_data_dst->rect.left = (left_right >>10 ) &0x3ff ; - q_data_dst->rect.top = (top_bottom >>10 ) &0x3ff ; +if (dev->devtype->product ==CODA_988 ) { + crop_shift =CODA_988_CROP_SHIFT ; + crop_mask =CODA_988_CROP_MASK ; + }else { + crop_shift =CODA_COMMON_CROP_SHIFT ; + crop_mask =CODA_COMMON_CROP_MASK ; + } + + q_data_dst->rect.left = (left_right >> crop_shift) & crop_mask; + q_data_dst->rect.top = (top_bottom >> crop_shift) & crop_mask; q_data_dst->rect.width = width - q_data_dst->rect.left - - (left_right &0x3ff ); + (left_right & crop_mask); q_data_dst->rect.height = height - q_data_dst->rect.top - - (top_bottom &0x3ff ); + (top_bottom & crop_mask); }if (dev->devtype->product !=CODA_DX6 ) {
@@ -2059,13 +2767,27 @@ static int __coda_start_decoding(struct coda_ctx *ctx)if (ret <0 )return ret; }else { - ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 <<9 ) | -CODA9_FRAME_TILED2LINEAR ); -if (dst_fourcc ==V4L2_PIX_FMT_NV12 || dst_fourcc ==V4L2_PIX_FMT_YUYV ) +if (dev->devtype->product ==CODA_988 ) { + ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | +CODA988_FRAME_CHROMA_NV21_SWAP | +CODA988_FRAME_TILED_MAP_MASK | +CODA988_FRAME_TILED2LINEAR_MASK ); +if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) { + ctx->frame_mem_ctrl |=CODA988_FRAME_TILED2LINEAR_FRAME_MAP | +CODA988_FRAME_TILED_MAP_TILED_FRAME_MB_RAST ; + } + }else { + ctx->frame_mem_ctrl &= ~(CODA_FRAME_CHROMA_INTERLEAVE | (0x3 <<9 ) | +CODA9_FRAME_TILED2LINEAR ); +if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) + ctx->frame_mem_ctrl |= (0x3 <<9 ) | + ((ctx->use_vdoa) ?0 :CODA9_FRAME_TILED2LINEAR ); + } +if (dst_fourcc ==V4L2_PIX_FMT_NV12 || dst_fourcc ==V4L2_PIX_FMT_NV21 || + dst_fourcc ==V4L2_PIX_FMT_YUYV ) ctx->frame_mem_ctrl |=CODA_FRAME_CHROMA_INTERLEAVE ; -if (ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) - ctx->frame_mem_ctrl |= (0x3 <<9 ) | - ((ctx->use_vdoa) ?0 :CODA9_FRAME_TILED2LINEAR ); +if (dst_fourcc ==V4L2_PIX_FMT_NV21 && dev->devtype->product ==CODA_988 ) + ctx->frame_mem_ctrl |=CODA988_FRAME_CHROMA_NV21_SWAP ; }coda_write (dev, ctx->parabuf.paddr,CODA_REG_BIT_PARA_BUF_ADDR );
@@ -2078,8 +2800,13 @@ static int __coda_start_decoding(struct coda_ctx *ctx)/* Tell the decoder how many frame buffers we allocated. */ coda_write (dev, ctx->num_internal_frames,CODA_CMD_SET_FRAME_BUF_NUM ); -coda_write (dev,round_up (q_data_dst->rect.width,16 ), -CODA_CMD_SET_FRAME_BUF_STRIDE ); +if (dev->devtype->product ==CODA_988 ) { +coda_write (dev,round_up (q_data_dst->rect.width,32 ), +CODA_CMD_SET_FRAME_BUF_STRIDE ); + }else { +coda_write (dev,round_up (q_data_dst->rect.width,16 ), +CODA_CMD_SET_FRAME_BUF_STRIDE ); + }if (dev->devtype->product !=CODA_DX6 ) {/* Set secondary AXI IRAM */
@@ -2095,15 +2822,23 @@ static int __coda_start_decoding(struct coda_ctx *ctx) CODA7_CMD_SET_FRAME_AXI_DBKC_ADDR);coda_write (dev, ctx->iram_info.buf_ovl_use,CODA7_CMD_SET_FRAME_AXI_OVL_ADDR ); -if (dev->devtype->product ==CODA_960 ) { -coda_write (dev, ctx->iram_info.buf_btp_use, -CODA9_CMD_SET_FRAME_AXI_BTP_ADDR ); - +if (dev->devtype->product ==CODA_960 || + dev->devtype->product ==CODA_988 ) {coda_write (dev,-1 ,CODA9_CMD_SET_FRAME_DELAY ); -coda9_set_frame_cache (ctx, dst_fourcc); +if (dev->devtype->product ==CODA_960 ) { +coda_write (dev, (u32 )ctx->iram_info.buf_btp_use, +CODA9_CMD_SET_FRAME_AXI_BTP_ADDR ); +coda9_set_frame_cache (ctx, dst_fourcc); + }else { +coda988_set_frame_cache (ctx, dst_fourcc); + } } } +if (src_fourcc ==V4L2_PIX_FMT_VP8 ) { +coda_write (dev, ctx->vp8mbbuf.paddr,CODA9_CMD_SET_FRAME_MB_BUF_BASE ); + } +if (src_fourcc ==V4L2_PIX_FMT_H264 ) {coda_write (dev, ctx->slicebuf.paddr,CODA_CMD_SET_FRAME_SLICE_BB_START );
@@ -2134,6 +2869,16 @@ static int __coda_start_decoding(struct coda_ctx *ctx)return -ETIMEDOUT ; } +if (dev->devtype->product ==CODA_988 ) { +u32 val =coda_read (dev,CODA988_RET_SET_FRAME_SUCCESS ); + +if (!(val &0x1 )) +pr_err ("SET_FRAME_SUCCESS = %d\n" , val); + +if (val & (1 <<31 )) +v4l2_err (&dev->v4l2_dev,"set frame: memory access violation\n" ); + } +return 0 ; }
@@ -2187,6 +2932,9 @@ static int coda_prepare_decode(struct coda_ctx *ctx)if (dev->devtype->product ==CODA_960 )coda_set_gdi_regs (ctx); +else if (dev->devtype->product ==CODA_988 && + ctx->tiled_map_type ==GDI_TILED_FRAME_MB_RASTER_MAP ) +coda988_set_gdi_regs (ctx); if (ctx->use_vdoa && ctx->display_idx >= 0 &&
@@ -2195,7 +2943,8 @@ static int coda_prepare_decode(struct coda_ctx *ctx)vb2_dma_contig_plane_dma_addr (&dst_buf->vb2_buf,0 ), ctx->internal_frames[ctx->display_idx].buf.paddr); }else { -if (dev->devtype->product ==CODA_960 ) { +if (dev->devtype->product ==CODA_960 || + dev->devtype->product ==CODA_988 ) {/* * It was previously assumed that the CODA960 has an * internal list of 64 buffer entries that contains
@@ -2239,12 +2988,19 @@ static int coda_prepare_decode(struct coda_ctx *ctx)/* 'hardcode to use interrupt disable mode'? */ coda_write (dev, (1 <<10 ),CODA_CMD_DEC_PIC_OPTION );break ; +case CODA_988 : +coda_write (dev,0x0 ,CODA988_CMD_DEC_PIC_USER_DATA_BASE_ADDR ); +coda_write (dev,0x0 ,CODA988_CMD_DEC_PIC_USER_DATA_BUF_SIZE ); +coda_write (dev,0x0 ,CODA988_CMD_DEC_PIC_NUM_ROWS ); +coda_write (dev,CODA988_UDATA_REPORT_INT_DISABLE ,CODA_CMD_DEC_PIC_OPTION ); +break ; } -coda_write (dev,0 ,CODA_CMD_DEC_PIC_SKIP_NUM ); - -coda_write (dev,0 ,CODA_CMD_DEC_PIC_BB_START ); -coda_write (dev,0 ,CODA_CMD_DEC_PIC_START_BYTE ); +if (dev->devtype->product !=CODA_988 ) { +coda_write (dev,0 ,CODA_CMD_DEC_PIC_SKIP_NUM ); +coda_write (dev,0 ,CODA_CMD_DEC_PIC_BB_START ); +coda_write (dev,0 ,CODA_CMD_DEC_PIC_START_BYTE ); + }if (dev->devtype->product !=CODA_DX6 ) coda_write(dev, ctx->iram_info.axi_sram_use,
@@ -2339,6 +3095,19 @@ static void coda_finish_decode(struct coda_ctx *ctx)v4l2_err (&dev->v4l2_dev,"insufficient slice buffer space (%d bytes)\n" , ctx->slicebuf.size); +if (ctx->dev->devtype->product ==CODA_988 && val & (1 <<16 )) +v4l2_err (&dev->v4l2_dev, +"in-stream should be reused by Non-Paired field\n" ); +if (ctx->dev->devtype->product ==CODA_988 && val & (1 <<17 )) +v4l2_err (&dev->v4l2_dev,"syntax error in the picture header\n" ); +if (ctx->dev->devtype->product ==CODA_988 && val & (1 <<19 )) +v4l2_err (&dev->v4l2_dev,"the current frame number is wrapped around\n" ); +if (ctx->dev->devtype->product ==CODA_988 && val & (1 <<20 )) +v4l2_err (&dev->v4l2_dev,"there is a change of sequence\n" ); +if (ctx->dev->devtype->product ==CODA_988 && val & (1 <<21 )) +v4l2_err (&dev->v4l2_dev,"reference frame is missing\n" ); +if (ctx->dev->devtype->product ==CODA_988 && val & (1 <<31 )) +v4l2_err (&dev->v4l2_dev,"pic dec: memory access violation\n" ); } val =coda_read (dev,CODA_RET_DEC_PIC_SIZE );
@@ -2624,6 +3393,10 @@ irqreturn_t coda_irq_handler(int irq, void *data)struct coda_dev *dev = data;struct coda_ctx *ctx;u32 status; +u32 irq_reason; + +if (dev->devtype->product ==CODA_988 ) + irq_reason =coda_read (dev,CODA_REG_BIT_INT_REASON );/* read status register to attend the IRQ */ status =coda_read (dev,CODA_REG_BIT_INT_STATUS );
@@ -2657,7 +3430,14 @@ irqreturn_t coda_irq_handler(int irq, void *data)coda_dbg (1 , ctx,"task has been aborted\n" ); } -if (coda_isbusy (ctx->dev)) { +if (dev->devtype->product ==CODA_988 ) { +if (irq_reason &CODA988_INT_BIT_BIT_BUF_FULL ) +coda_dbg (1 , ctx,"Error! External bitsteam buffer is in full status\n" ); +else if (irq_reason &CODA988_INT_BIT_BIT_BUF_EMPTY ) +coda_dbg (1 , ctx,"Error! External bitsteam buffer is in empty status\n" ); + } + +if (coda_isbusy (ctx->dev,CODA_REG_BIT_BUSY )) {coda_dbg (1 , ctx,"coda is still busy!!!!\n" );return IRQ_NONE ; }
drivers/media/platform/chips-media/coda/coda-common.c +350 -32
579 lines not on this page · raw message
drivers/media/platform/chips-media/coda/coda-gdi.c +149 -0
158 lines not on this page · raw message
drivers/media/platform/chips-media/coda/coda-h264.c +10 -0
@@ -89,6 +89,16 @@ int coda_h264_profile(int profile_idc) } } +int coda_h264enc_profile_id (int profile_idc) +{ +switch (profile_idc) { +case 66 :return 0 ; +case 77 :return 1 ; +case 100 :return 2 ; +default :return 2 ; + } +} +int coda_h264_level (int level_idc) {switch (level_idc) {
drivers/media/platform/chips-media/coda/coda.h +36 -1
@@ -27,10 +27,18 @@#include "coda_regs.h" #define CODA_MAX_FRAMEBUFFERS 19 +#define CODA988_MIN_FRAMEBUFFERS 8#define FMO_SLICE_SAVE_BUF_SIZE (32)#define CODA_DEFAULT_GAMMA 4096#define CODA9_DEFAULT_GAMMA 24576/* 0.75 * 32768 */ +#define CODA988_DEFAULT_GAMMA 0/* uses value defined in FW */ + +#define CODADX6_MAX_GOP_SIZE 60 +#define CODA_MAX_GOP_SIZE 99 + +#define CODA_MAX_BITRATE 32767000 +#define CODA988_MAX_BITRATE 262143000/* * This control allows applications to read the per-stream
@@ -54,6 +62,7 @@ enum coda_product {CODA_HX4 =0xf00a ,CODA_7541 =0xf012 ,CODA_960 =0xf020 , + CODA_988 = 0xcc28, };struct coda_video_device ;
@@ -133,6 +142,8 @@ struct coda_params {u8 mpeg2_level_idc;u8 mpeg4_intra_qp;u8 mpeg4_inter_qp; +u8 h263_intra_qp; +u8 h263_inter_qp;u8 gop_size;int intra_refresh;enum v4l2_jpeg_chroma_subsampling jpeg_chroma_subsampling;
@@ -148,7 +159,7 @@ struct coda_params {int codec_mode_aux;enum v4l2_mpeg_video_multi_slice_mode slice_mode;u32 framerate; -u16 bitrate; +u32 bitrate;u16 vbv_delay;u32 vbv_size;u32 slice_max_bits;
@@ -163,6 +174,25 @@ struct coda_params {bool slice_mode_changed;bool frame_rc_enable;bool mb_rc_enable; +bool entropy_mode_changed; +u8 bitrate_mode; +u32 frame_skip_mode; +u8 h264_min_i_qp; +u8 h264_max_i_qp; +u8 h264_min_p_qp; +u8 h264_max_p_qp; +u8 h264_entropy_mode; +u8 h264_en_8x8_transform; +int h264_i_frame_period; +bool encode_aud_en; +u8 me_search_range_x; +u8 me_search_range_y; +u8 h263_min_qp; +u8 h263_max_qp; +u8 mpeg4_min_qp; +u8 mpeg4_max_qp; +u32 max_intra_size; +u8 vp8_fill_ivf_header; };struct coda_buffer_meta {
@@ -269,6 +299,7 @@ struct coda_ctx {struct coda_aux_buf parabuf;struct coda_aux_buf psbuf;struct coda_aux_buf slicebuf; +struct coda_aux_buf vp8mbbuf;struct coda_internal_frame internal_frames[CODA_MAX_FRAMEBUFFERS ];struct list_head buffer_meta_list;spinlock_t buffer_meta_lock;
@@ -325,6 +356,7 @@ int coda_hw_reset(struct coda_ctx *ctx);void coda_fill_bitstream (struct coda_ctx *ctx,struct list_head *buffer_list);void coda_set_gdi_regs (struct coda_ctx *ctx); +void coda988_set_gdi_regs (struct coda_ctx *ctx);static inline struct coda_q_data *get_q_data (struct coda_ctx *ctx,enum v4l2_buf_type type)
@@ -369,6 +401,7 @@ void coda_m2m_buf_done(struct coda_ctx *ctx, struct vb2_v4l2_buffer *buf,int coda_h264_filler_nal (int size,char *p);int coda_h264_padding (int size,char *p);int coda_h264_profile (int profile_idc); +int coda_h264enc_profile_id (int profile_idc);int coda_h264_level (int level_idc);int coda_sps_parse_profile (struct coda_ctx *ctx,struct vb2_buffer *vb); int coda_h264_sps_fixup(struct coda_ctx *ctx, int width, int height, char *buf,
@@ -395,6 +428,7 @@ bool coda_jpeg_check_buffer(struct coda_ctx *ctx, struct vb2_buffer *vb);int coda_jpeg_decode_header (struct coda_ctx *ctx,struct vb2_buffer *vb);int coda_jpeg_write_tables (struct coda_ctx *ctx);void coda_set_jpeg_compression_quality (struct coda_ctx *ctx,int quality); +int coda988_hw_init_reset (struct coda_dev *dev);extern const struct coda_context_ops coda_bit_encode_ops;extern const struct coda_context_ops coda_bit_decode_ops;
@@ -404,4 +438,5 @@ extern const struct coda_context_ops coda9_jpeg_decode_ops;irqreturn_t coda_irq_handler (int irq,void *data);irqreturn_t coda9_jpeg_irq_handler (int irq,void *data); +int coda_wait_timeout (struct coda_dev *dev,uint32_t reg_busy);#endif /* __CODA_H__ */
drivers/media/platform/chips-media/coda/coda_regs.h +157 -0
335 lines not on this page · raw message
Signature · 1 line
2.30.2
Hi Sergey
Can you share the result of fluster test for h264 and vp8 decoder?
Thanks
Jackson
Quoted 96 lines
-----Original Message-----
From: Sergey Khimich <[email protected]>
Sent: Saturday, March 15, 2025 12:29 AM
To: [email protected]
Cc: Philipp Zabel <[email protected]>; Mauro Carvalho Chehab <[email protected]>; [email protected]; Vladimir Yakovlev <[email protected]>; Maksim Turok <[email protected]>
Subject: [PATCH 00/18] coda988 video codec supportHello!
This is the implementation of the Chips&Media "CODA988" video codec support within v4l2 driver for coda. Support for the following codecs was implemented:
* h264: decoder & encoder * h263: decoder & encoder * mpeg4: decoder & encoder* vp8dec: decoder
Support for the following formates was implemented:
* yuv420p(I420)
* yvu420p(YV12)
* NV12
* NV21Also the following features and fixes were implemented for coda988:
* special config formem_ctrl
* special config for encoder header (sps and pps)
* special setprofile_idc
* special set RC config
* special set QP
* special set slice mode
* special set Motion Extimation (ME)
*v4l2_ctrlfor h264 profile
*v4l2_ctrlfor h264 level
*v4l2_ctrlfor h.264 RC mode
*v4l2_ctrlfor h.264 skipFrame
*v4l2_ctrlfor h.264 i-frame min/max qp
*v4l2_ctrlfor h.264 p-frame min/max qp
*v4l2_ctrlfor h.264 entropy mode
*v4l2_ctrlfor h.264 8x8transform
*v4l2_ctrlfor h.264 i-frame period
*v4l2_ctrlfor h.264 Access Unit Delimiter(AUD)
*v4l2_ctrlfor h.264 me x/y search range
*v4l2_ctrlfor h.264 intra refresh period
*v4l2_ctrlfor h.263 intra/inter qp
*v4l2_ctrlfor h.263 min/max qp
*v4l2_ctrlfor mpeg4 min/max qpDuring adding support for "CODA988" we also did some extra work related to refactoring and improvement of generic part of C&M coda driver:
* Improve error checking for probe, irq-handle and etc.
* Update work with resets
* Replacehard_irqbythreaded_irq
* Remove double setting of stop flag
* Improve some prints
* Fix loglevel to avoid performance failure
* Fix support of MPEG4 levels
* Fix setting gamma for h264enc
* Update default velues of QP for mpeg4 I/P
* Other minor fixesSergey Khimich (18):
media: coda: Add print if irq isn't present
media: coda: Useget_arrayto work use multiple reset
dt-bindings: media: coda: Fix resets count
media: coda: Add check result after reset
media: coda: usingthreaded_irqfor 0 (bit) interrupt
media: coda: Add reset device before getting interrupt
media: coda: Add fake IRQ check
media: coda: Add log tofinish_encodeif buffer is too small
media: coda: Fix max h.264 level forCODA_DX6
media: coda: Remove double setting of stop flag
media: coda: Print size of encoded buff in other place
media: coda: Fix loglevel for seq mismatch print
media: coda: Fix support for all mpeg4 levels
media: coda: Fix handling wrong format incoda_try_fmt
media: coda: Usev4l2_ctrlto set gamma for h264enc
media: coda: Update default velues of QP for mpeg4 I/P
media: coda: Use preferredusleep_rangethan udelay
media: coda: add support coda988 enc and dec.../devicetree/bindings/media/coda.yaml | 2 +- .../platform/chips-media/coda/coda-bit.c | 1114 ++++++++++++++--- .../platform/chips-media/coda/coda-common.c | 430 ++++++- .../platform/chips-media/coda/coda-gdi.c | 149 +++ .../platform/chips-media/coda/coda-h264.c | 10 + .../media/platform/chips-media/coda/coda.h | 41 +- .../platform/chips-media/coda/coda_regs.h | 157 +++ .../media/platform/chips-media/coda/trace.h | 16 + 8 files changed, 1703 insertions(+), 216 deletions(-)--
2.30.2
Hi Sergey
I checked your result.
The all VP8 test cases should be passed.
In case of H264, all test cases should be passed except these "CVFC1_Sony_C, FM1_BT_B, FM1_FT_E, SP1_BT_A and sp2_bt_b"
But your result has some fail or error for the H264 and VP8 decoder, Can you check them?
Thanks
Jackson
Quoted 114 lines
-----Original Message-----
From: jackson.lee <[email protected]>
Sent: Monday, March 17, 2025 9:13 AM
To: Sergey Khimich <[email protected]>; [email protected]
Cc: Philipp Zabel <[email protected]>; Mauro Carvalho Chehab <[email protected]>; [email protected]; Vladimir Yakovlev <[email protected]>; Maksim Turok <[email protected]>
Subject: RE: [PATCH 00/18] coda988 video codec supportHi Sergey
Can you share the result of fluster test for h264 and vp8 decoder?
Thanks
JacksonQuoted 97 lines
-----Original Message-----
From: Sergey Khimich <[email protected]>
Sent: Saturday, March 15, 2025 12:29 AM
To: [email protected]
Cc: Philipp Zabel <[email protected]>; Mauro Carvalho Chehab <[email protected]>; [email protected]; Vladimir Yakovlev <[email protected]>; Maksim Turok <[email protected]>
Subject: [PATCH 00/18] coda988 video codec supportHello!
This is the implementation of the Chips&Media "CODA988" video codec support within v4l2 driver for coda. Support for the following codecs was
implemented:* h264: decoder & encoder * h263: decoder & encoder * mpeg4: decoder & encoder* vp8dec: decoder
Support for the following formates was implemented:
* yuv420p(I420)
* yvu420p(YV12)
* NV12
* NV21Also the following features and fixes were implemented for coda988:
* special config formem_ctrl
* special config for encoder header (sps and pps)
* special setprofile_idc
* special set RC config
* special set QP
* special set slice mode
* special set Motion Extimation (ME)
*v4l2_ctrlfor h264 profile
*v4l2_ctrlfor h264 level
*v4l2_ctrlfor h.264 RC mode
*v4l2_ctrlfor h.264 skipFrame
*v4l2_ctrlfor h.264 i-frame min/max qp
*v4l2_ctrlfor h.264 p-frame min/max qp
*v4l2_ctrlfor h.264 entropy mode
*v4l2_ctrlfor h.264 8x8transform
*v4l2_ctrlfor h.264 i-frame period
*v4l2_ctrlfor h.264 Access Unit Delimiter(AUD)
*v4l2_ctrlfor h.264 me x/y search range
*v4l2_ctrlfor h.264 intra refresh period
*v4l2_ctrlfor h.263 intra/inter qp
*v4l2_ctrlfor h.263 min/max qp
*v4l2_ctrlfor mpeg4 min/max qpDuring adding support for "CODA988" we also did some extra work related to refactoring and improvement of generic part of C&M coda driver:
* Improve error checking for probe, irq-handle and etc.
* Update work with resets
* Replacehard_irqbythreaded_irq
* Remove double setting of stop flag
* Improve some prints
* Fix loglevel to avoid performance failure
* Fix support of MPEG4 levels
* Fix setting gamma for h264enc
* Update default velues of QP for mpeg4 I/P
* Other minor fixesSergey Khimich (18):
media: coda: Add print if irq isn't present
media: coda: Useget_arrayto work use multiple reset
dt-bindings: media: coda: Fix resets count
media: coda: Add check result after reset
media: coda: usingthreaded_irqfor 0 (bit) interrupt
media: coda: Add reset device before getting interrupt
media: coda: Add fake IRQ check
media: coda: Add log tofinish_encodeif buffer is too small
media: coda: Fix max h.264 level forCODA_DX6
media: coda: Remove double setting of stop flag
media: coda: Print size of encoded buff in other place
media: coda: Fix loglevel for seq mismatch print
media: coda: Fix support for all mpeg4 levels
media: coda: Fix handling wrong format incoda_try_fmt
media: coda: Usev4l2_ctrlto set gamma for h264enc
media: coda: Update default velues of QP for mpeg4 I/P
media: coda: Use preferredusleep_rangethan udelay
media: coda: add support coda988 enc and dec.../devicetree/bindings/media/coda.yaml | 2 +- .../platform/chips-media/coda/coda-bit.c | 1114 ++++++++++++++--- .../platform/chips-media/coda/coda-common.c | 430 ++++++- .../platform/chips-media/coda/coda-gdi.c | 149 +++ .../platform/chips-media/coda/coda-h264.c | 10 + .../media/platform/chips-media/coda/coda.h | 41 +- .../platform/chips-media/coda/coda_regs.h | 157 +++ .../media/platform/chips-media/coda/trace.h | 16 + 8 files changed, 1703 insertions(+), 216 deletions(-)--
2.30.2
Hi Philipp,
any plans to review this series ?
Nicolas
Le vendredi 14 mars 2025 à 18:29 +0300, Sergey Khimich a écrit :
Quoted 85 lines
Hello!
This is the implementation of the Chips&Media "CODA988" video codec support
within v4l2 driver for coda. Support for the following codecs was implemented:
* h264: decoder & encoder
* h263: decoder & encoder
* mpeg4: decoder & encoder
* vp8dec: decoderSupport for the following formates was implemented:
* yuv420p(I420)
* yvu420p(YV12)
* NV12
* NV21Also the following features and fixes were implemented for coda988:
* special config formem_ctrl
* special config for encoder header (sps and pps)
* special setprofile_idc
* special set RC config
* special set QP
* special set slice mode
* special set Motion Extimation (ME)
*v4l2_ctrlfor h264 profile
*v4l2_ctrlfor h264 level
*v4l2_ctrlfor h.264 RC mode
*v4l2_ctrlfor h.264 skipFrame
*v4l2_ctrlfor h.264 i-frame min/max qp
*v4l2_ctrlfor h.264 p-frame min/max qp
*v4l2_ctrlfor h.264 entropy mode
*v4l2_ctrlfor h.264 8x8transform
*v4l2_ctrlfor h.264 i-frame period
*v4l2_ctrlfor h.264 Access Unit Delimiter(AUD)
*v4l2_ctrlfor h.264 me x/y search range
*v4l2_ctrlfor h.264 intra refresh period
*v4l2_ctrlfor h.263 intra/inter qp
*v4l2_ctrlfor h.263 min/max qp
*v4l2_ctrlfor mpeg4 min/max qpDuring adding support for "CODA988" we also did some extra work related to refactoring and improvement of generic part of C&M coda driver:
* Improve error checking for probe, irq-handle and etc.
* Update work with resets
* Replacehard_irqbythreaded_irq
* Remove double setting of stop flag
* Improve some prints
* Fix loglevel to avoid performance failure
* Fix support of MPEG4 levels
* Fix setting gamma for h264enc
* Update default velues of QP for mpeg4 I/P
* Other minor fixesSergey Khimich (18):
media: coda: Add print if irq isn't present
media: coda: Useget_arrayto work use multiple reset
dt-bindings: media: coda: Fix resets count
media: coda: Add check result after reset
media: coda: usingthreaded_irqfor 0 (bit) interrupt
media: coda: Add reset device before getting interrupt
media: coda: Add fake IRQ check
media: coda: Add log tofinish_encodeif buffer is too small
media: coda: Fix max h.264 level forCODA_DX6
media: coda: Remove double setting of stop flag
media: coda: Print size of encoded buff in other place
media: coda: Fix loglevel for seq mismatch print
media: coda: Fix support for all mpeg4 levels
media: coda: Fix handling wrong format incoda_try_fmt
media: coda: Usev4l2_ctrlto set gamma for h264enc
media: coda: Update default velues of QP for mpeg4 I/P
media: coda: Use preferredusleep_rangethan udelay
media: coda: add support coda988 enc and dec.../devicetree/bindings/media/coda.yaml | 2 +- .../platform/chips-media/coda/coda-bit.c | 1114 ++++++++++++++- --
.../platform/chips-media/coda/coda-common.c | 430 ++++++- .../platform/chips-media/coda/coda-gdi.c | 149 +++ .../platform/chips-media/coda/coda-h264.c | 10 + .../media/platform/chips-media/coda/coda.h | 41 +- .../platform/chips-media/coda/coda_regs.h | 157 +++ .../media/platform/chips-media/coda/trace.h | 16 +8 files changed, 1703 insertions(+), 216 deletions(-)