Message ID | 20220427224438.335327-1-frattaroli.nicolas@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | Enable JPEG Encoder on RK3566/RK3568 | expand |
Le jeudi 28 avril 2022 à 00:44 +0200, Nicolas Frattaroli a écrit : > Hello, > > the following series adds support for and enables the hardware JPEG > encoder on the RK3566 and RK3568 line of SoCs by Rockchip. > > The JPEG encoder is its own little Hantro instance with seemingly just > the encode functionality. I'm a little suspicious about this statement. I believe the Hantro combo is identical to RK3399 and that you are confusing with Rockchip JPEG encoder here. Here's the source of my suspicion: https://github.com/JeffyCN/rockchip_mirrors/blob/mpp/osal/mpp_soc.cpp#L637 As this get burnt into DT, we really need to get this right. Perhaps we need to run the reference software to verify ? Ping me if you need help with that. > > The first patch modifies the bindings with a new compatible, and adds > the ability to just have a vepu interrupt without a vdpu interrupt. > > The second patch makes the actual driver changes to support this variant. > > The third and final patch makes the necessary device tree changes for > the rk356x device tree file to add both the node for the encoder and > its MMU. > > The series has been tested on a PINE64 Quartz64 Model A with an RK3566 > SoC using GStreamer. > > Regards, > Nicolas Frattaroli > > Nicolas Frattaroli (3): > dt-bindings: media: rockchip-vpu: Add RK3568 JPEG compatible > media: hantro: Add support for RK356x JPEG encoder > arm64: dts: rockchip: Add JPEG encoder node to rk356x > > .../bindings/media/rockchip-vpu.yaml | 2 + > arch/arm64/boot/dts/rockchip/rk356x.dtsi | 21 +++++++ > drivers/staging/media/hantro/hantro_drv.c | 1 + > drivers/staging/media/hantro/hantro_hw.h | 1 + > .../staging/media/hantro/rockchip_vpu_hw.c | 62 +++++++++++++++++++ > 5 files changed, 87 insertions(+) >
On Freitag, 29. April 2022 16:46:01 CEST Nicolas Dufresne wrote: > Le jeudi 28 avril 2022 à 00:44 +0200, Nicolas Frattaroli a écrit : > > Hello, > > > > the following series adds support for and enables the hardware JPEG > > encoder on the RK3566 and RK3568 line of SoCs by Rockchip. > > > > The JPEG encoder is its own little Hantro instance with seemingly just > > the encode functionality. > > I'm a little suspicious about this statement. I believe the Hantro combo is > identical to RK3399 and that you are confusing with Rockchip JPEG encoder here. > Here's the source of my suspicion: > > https://github.com/JeffyCN/rockchip_mirrors/blob/mpp/osal/mpp_soc.cpp#L637 > > As this get burnt into DT, we really need to get this right. Perhaps we need to > run the reference software to verify ? Ping me if you need help with that. I believe there's three separate questions here: A) is this a Hantro instance with more than just JPEG encoding? B) is this the same as the other[1] Hantro instance, just with a bigger offset for the encoder? C) if A is true and B is false, does this also have decoders? I think I can only answer B). I do not think fdee0000 is the same hardware instance as fdea0400. They are in different power domains (yes, this one being in the RGA PD is correct according to downstream code, TRM and my own testing). They also have their own MMU each. Your findings point towards A) being true. I'd love to be able to just throw a mainline VP8 or H.264 driver at it to check, but that sadly does not exist yet. Upon checking the TRM again, it seems it documents registers for H.264 as well. However I can do this to answer C), and I will once I get the time. It would be somewhat surprising if there was a hidden third H.264 decoder on this chip. I'll also CC Kever Yang from rockchip, maybe he can shine some light on this. Regards, Nicolas Frattaroli [1]: https://patchwork.kernel.org/project/linux-rockchip/patch/20220214212955.1178947-2-piotr.oniszczuk@gmail.com/ > > > > > The first patch modifies the bindings with a new compatible, and adds > > the ability to just have a vepu interrupt without a vdpu interrupt. > > > > The second patch makes the actual driver changes to support this variant. > > > > The third and final patch makes the necessary device tree changes for > > the rk356x device tree file to add both the node for the encoder and > > its MMU. > > > > The series has been tested on a PINE64 Quartz64 Model A with an RK3566 > > SoC using GStreamer. > > > > Regards, > > Nicolas Frattaroli > > > > Nicolas Frattaroli (3): > > dt-bindings: media: rockchip-vpu: Add RK3568 JPEG compatible > > media: hantro: Add support for RK356x JPEG encoder > > arm64: dts: rockchip: Add JPEG encoder node to rk356x > > > > .../bindings/media/rockchip-vpu.yaml | 2 + > > arch/arm64/boot/dts/rockchip/rk356x.dtsi | 21 +++++++ > > drivers/staging/media/hantro/hantro_drv.c | 1 + > > drivers/staging/media/hantro/hantro_hw.h | 1 + > > .../staging/media/hantro/rockchip_vpu_hw.c | 62 +++++++++++++++++++ > > 5 files changed, 87 insertions(+) > > > >
Hi, On Fri, Apr 29, 2022 at 05:28:35PM +0200, Nicolas Frattaroli wrote: >On Freitag, 29. April 2022 16:46:01 CEST Nicolas Dufresne wrote: >> Le jeudi 28 avril 2022 à 00:44 +0200, Nicolas Frattaroli a écrit : >> > the following series adds support for and enables the hardware JPEG >> > encoder on the RK3566 and RK3568 line of SoCs by Rockchip. >> > >> > The JPEG encoder is its own little Hantro instance with seemingly just >> > the encode functionality. >> >> I'm a little suspicious about this statement. I believe the Hantro combo is >> identical to RK3399 and that you are confusing with Rockchip JPEG encoder here. >> Here's the source of my suspicion: >> >> https://github.com/JeffyCN/rockchip_mirrors/blob/mpp/osal/mpp_soc.cpp#L637 >> >> As this get burnt into DT, we really need to get this right. Perhaps we need to >> run the reference software to verify ? Ping me if you need help with that. > >I believe there's three separate questions here: > >A) is this a Hantro instance with more than just JPEG encoding? >B) is this the same as the other[1] Hantro instance, just with a bigger > offset for the encoder? >C) if A is true and B is false, does this also have decoders? > >I think I can only answer B). I do not think fdee0000 is the same hardware >instance as fdea0400. They are in different power domains (yes, this one >being in the RGA PD is correct according to downstream code, TRM and my >own testing). They also have their own MMU each. >Your findings point towards A) being true. I'd love to be able to just >throw a mainline VP8 or H.264 driver at it to check, but that sadly does >not exist yet. Not Mainline, but for the the RK3399 Encoder there is some initial work available made by bootlin. https://github.com/bootlin/linux bootlin/hantro/h264-encoding-v5.11 They also implemented some initial userspace tool to test this. https://github.com/bootlin/v4l2-hantro-h264-encoder If you have some time on your hands, it would be great if we could test this on the RK3568 with the VEPU121 core. >Upon checking the TRM again, it seems it documents registers for H.264 as well. I would like to describe the whole sitation a little bit more in detail. In the Datasheet of the RK3568 there are several decoder and encoder entities documented. This encoder instance is called VEPU121 in the TRM. RK3568: ------- Look into "Chapter 10 Multi-format Video Encoder and Decoder" (Page 463) of RK3568 TRM Part2. https://dl.radxa.com/rock3/docs/hw/datasheet/Rockchip%20RK3568%20TRM%20Part2%20V1.1-20210301.pdf We also find some mentionioning of JPEG encoding in the RK3399 datasheet. RK3399: ------- Look into "Chapter 5 Multi-format Video Decoder And Encoder" (Page 297) of RK3399 TRM Part 3. http://www.netbsd.org/~mrg/rk3399/Rockchip%20RK3399TRM%20V1.1%20Part3%2020160728.pdf * Supports encoding of the following standards: * H.264: up to HP level 4.1 * JPEG: Baseline (DCT sequential) Which probably refers to the core that is also available on the RK3399. Comparing the register layout of VEPU121 of the RK3568 with the encoder part in RK3399 we find nearly the same register description. 10.5.21 VEPU121 Detail Registers Description (Page 704 of RK3568 TRM Part2) vs. 5.5.4 VEPU Registers Summary (Page 443 of RK3399 TRM Part3) However this is just the documentation, this could mean nothing to the real world. Getting the core tested with the bootlin stack or getting feedback from Kever would probably tell the whole story. >However I can do this to answer C), and I will once I get the time. >It would be somewhat surprising if there was a hidden third H.264 >decoder on this chip. The corresponding decoder world on the RK3568 is also very unclear. It supports RKVDEC (referd as VDPU346 in the TRM), that is probably also supported by the mainline code you can find in drivers/staging/media/rkvdec/. Then there is VDPU121 which seems to be just the same G1 as in RK3399, regarding to these patches: https://lore.kernel.org/all/20220213195316.4149106-3-piotr.oniszczuk@gmail.com/T/ The last Core you probably refer to is called VDPU720 JPEG Decoder located at 0xFDED0000. I also really don't know where to put this in at the moment. >I'll also CC Kever Yang from rockchip, maybe he can shine some light on >this. Since the RK3568 seems to get more and more of attention at the moment I would like to ask if somebody is planning to write support the RKVENC in mainline. That is the VEPU540 core refered to in the RK3568 TRM. I would start with that in the next weeks, taking the bootlin H1 support as an reference to handle the request_api for the encoder part. Which is currently completely untouched in mainline AFAIK. Regards, Michael
Hi Michael, Le samedi 30 avril 2022 à 01:20 +0200, Michael Grzeschik a écrit : > Since the RK3568 seems to get more and more of attention at the moment > I would like to ask if somebody is planning to write support the RKVENC > in mainline. That is the VEPU540 core refered to in the RK3568 TRM. > > I would start with that in the next weeks, taking the bootlin H1 support > as an reference to handle the request_api for the encoder part. Which is > currently completely untouched in mainline AFAIK. I'm very happy to ear you'd be interest in helping with this. I'm adding Andrzej in CC, as he started some base work using VP8 encoder on RK3399 (same HW found on other RK SoC) to make this possible. Note that these are a new type of encoders and a specification is needed to ensure they all have a coherent work- flow. The first step was obviously to have working prototype, Bootlin started with H264 (but never posted anything on the mailing list). I'm under the impression they have abandoned it. Andrzej have decided to use VP8 as it is simpler. The prototype should help understand the basic flow of an encoder and produce a specification for this. From there, the "easy" part is to make per codec controls, to configure the encoder. Demonstrating fixed QP, this is about were I believe Bootlin stopped. And I personally believe some OSS userland (not just tests) that can handle multiple reference, perhaps more advance GOP pattern and some basic rate control would help build confidence in the uAPI. Let us know how we can help, we should avoid doing the same thing, as this is already quite a large project that can easily take over a year to become mainline ready. regards, Nicolas > > Regards, > Michael >
Hi Nicolas, Hi Andrzej, On Mon, May 02, 2022 at 08:20:50AM -0400, Nicolas Dufresne wrote: >Le samedi 30 avril 2022 à 01:20 +0200, Michael Grzeschik a écrit : >> Since the RK3568 seems to get more and more of attention at the moment >> I would like to ask if somebody is planning to write support the RKVENC >> in mainline. That is the VEPU540 core refered to in the RK3568 TRM. >> >> I would start with that in the next weeks, taking the bootlin H1 support >> as an reference to handle the request_api for the encoder part. Which is >> currently completely untouched in mainline AFAIK. > >I'm very happy to ear you'd be interest in helping with this. I'm adding Andrzej >in CC, as he started some base work using VP8 encoder on RK3399 (same HW found >on other RK SoC) to make this possible. Note that these are a new type of >encoders and a specification is needed to ensure they all have a coherent work- >flow. The first step was obviously to have working prototype, Bootlin started >with H264 (but never posted anything on the mailing list). I'm under the >impression they have abandoned it. Andrzej have decided to use VP8 as it is >simpler. The prototype should help understand the basic flow of an encoder and >produce a specification for this. I just have tested the bootlin v4l2-h264-encoder stack on the rk3399 with v5.19-rc2. It is working as expected. Since there have been some rumours about using the VEPU121 core on the rk3568, which could have h264 support as well. I have tested this stack on that core as well. The findings are; It is producing some data, but the stream created is not possible to be decoded. Tested with vlc and gstreamer. Be it due to misconfiguration or the core is really not h264 capable. Find the latest code here: https://git.pengutronix.de/cgit/mgr/linux/log/?h=v5.19/topic/rk3568-vepu-h264-stateless-bootlin >From there, the "easy" part is to make per codec controls, to configure the >encoder. Demonstrating fixed QP, this is about were I believe Bootlin stopped. I have seen that the userspace tool is filling in some initial values in the PPS and SPS headers, which are not adjustable. I bet you refer to that. >And I personally believe some OSS userland (not just tests) that can handle >multiple reference, perhaps more advance GOP pattern and some basic rate control >would help build confidence in the uAPI. I found the following CTRL Types being defined in the bootlin stack for the request API. V4L2_CID_STATELESS_H264_ENCODE_PARAMS V4L2_CID_STATELESS_H264_ENCODE_RC V4L2_CID_STATELESS_H264_ENCODE_FEEDBACK The FEEDBACK CID is the information we gain after one frame was encoded. With this data the RC (Rate Control) parameter is prepared for the next frame. You mean to have some user interface to make the rate control user configurable? >Let us know how we can help, we should >void doing the same thing, as >this is already quite a large project that can easily take over a year >to become mainline ready. It would probably help to share some codebase. If you already have something for that rkvenc codec, be it VP8 support. It would probably make sense for me to build up on that. Or to discuss common code patterns on structures. Michael
Le lundi 20 juin 2022 à 15:40 +0200, Michael Grzeschik a écrit : > Hi Nicolas, > Hi Andrzej, > > On Mon, May 02, 2022 at 08:20:50AM -0400, Nicolas Dufresne wrote: > > Le samedi 30 avril 2022 à 01:20 +0200, Michael Grzeschik a écrit : > > > Since the RK3568 seems to get more and more of attention at the moment > > > I would like to ask if somebody is planning to write support the RKVENC > > > in mainline. That is the VEPU540 core refered to in the RK3568 TRM. > > > > > > I would start with that in the next weeks, taking the bootlin H1 support > > > as an reference to handle the request_api for the encoder part. Which is > > > currently completely untouched in mainline AFAIK. > > > > I'm very happy to ear you'd be interest in helping with this. I'm adding Andrzej > > in CC, as he started some base work using VP8 encoder on RK3399 (same HW found > > on other RK SoC) to make this possible. Note that these are a new type of > > encoders and a specification is needed to ensure they all have a coherent work- > > flow. The first step was obviously to have working prototype, Bootlin started > > with H264 (but never posted anything on the mailing list). I'm under the > > impression they have abandoned it. Andrzej have decided to use VP8 as it is > > simpler. The prototype should help understand the basic flow of an encoder and > > produce a specification for this. > > I just have tested the bootlin v4l2-h264-encoder stack on the rk3399 > with v5.19-rc2. It is working as expected. > > Since there have been some rumours about using the VEPU121 core on the > rk3568, which could have h264 support as well. I have tested this > stack on that core as well. > > The findings are; It is producing some data, but the stream created > is not possible to be decoded. Tested with vlc and gstreamer. Oh well, I'd say unless vendor document it, we'll not going to just enable it there. There is another (and faster) encoder there with an vendor but fully Open Source stack anyway. Thanks for the extra step here. > > Be it due to misconfiguration or the core is really not h264 capable. > > Find the latest code here: > > https://git.pengutronix.de/cgit/mgr/linux/log/?h=v5.19/topic/rk3568-vepu-h264-stateless-bootlin > > > From there, the "easy" part is to make per codec controls, to configure the > > encoder. Demonstrating fixed QP, this is about were I believe Bootlin stopped. > > I have seen that the userspace tool is filling in some initial values > in the PPS and SPS headers, which are not adjustable. I bet you refer to that. > > > And I personally believe some OSS userland (not just tests) that can handle > > multiple reference, perhaps more advance GOP pattern and some basic rate control > > would help build confidence in the uAPI. > > I found the following CTRL Types being defined in the bootlin stack > for the request API. > > V4L2_CID_STATELESS_H264_ENCODE_PARAMS > V4L2_CID_STATELESS_H264_ENCODE_RC > V4L2_CID_STATELESS_H264_ENCODE_FEEDBACK > > The FEEDBACK CID is the information we gain after one frame was > encoded. With this data the RC (Rate Control) parameter is prepared for > the next frame. > > You mean to have some user interface to make the rate control user > configurable? RC feedback controls are going to all be vendor specific. This one cannot be called with a generic name like "ENCODE_FEEDBACK" since it is not generic. In fact, news Hantro chip don't have this feedback, they have something else but it is not used by the vendor software (not open source, but you can find leaks I suppose). They only use the size of the compressed frames, and do RC in software there. In addition to that, with the current trend, "feedback" controls would have to use RO Request, so that one can still queue multiple encode and be able to match the feedback to a specific request/frame. > > > Let us know how we can help, we should >void doing the same thing, as > > this is already quite a large project that can easily take over a year > > to become mainline ready. > > It would probably help to share some codebase. If you already have > something for that rkvenc codec, be it VP8 support. It would probably > make sense for me to build up on that. Or to discuss common code > patterns on structures. We are doing the exercise with VP8 using the original Hantro G1 design, as fond on IMX8MQ and RK3288. Though we only test on NXP boards at the moment. Andrzej is on vacation this week, I'll check with him why hist draft isn't accessible to the public. Meanwhile, the userland / GStreamer part is drafted (careful its a draft) here: https://gitlab.freedesktop.org/benjamin.gaignard1/gstreamer/-/tree/WIP_V4L2_VP8_STATELESS_ENCODER Currently we are still working on very basic bit of the puzzle, understanding the problem in order to produce a proper Stateless Encoder specification. As an example, the Hantro VP8 encoder brought interesting aspect, as an example it produces 2 buffers. Shall we offset these into 1 buffer, shall we use planes to zero copy that to user, or shall we memcpy in the driver .. Shall the VP8 frame header be produced by the driver (even though the HW don't produce it) or shall we have more stateless VP8 format for both cases. Its a big series of tiny things like this that we need to study and weight, and compare against other Hardware designs. regards, Nicolas